fix: chrome.tabs.update
return value (#39365)
fix: chrome.tabs.update return value
This commit is contained in:
parent
330c775252
commit
67523a47b4
4 changed files with 43 additions and 0 deletions
|
@ -950,6 +950,23 @@ describe('chrome extensions', () => {
|
|||
expect(response.status).to.equal('reloaded');
|
||||
});
|
||||
});
|
||||
|
||||
it('update', async () => {
|
||||
await w.loadURL(url);
|
||||
|
||||
const message = { method: 'update', args: [{ muted: true }] };
|
||||
w.webContents.executeJavaScript(`window.postMessage('${JSON.stringify(message)}', '*')`);
|
||||
|
||||
const [,, responseString] = await once(w.webContents, 'console-message');
|
||||
const response = JSON.parse(responseString);
|
||||
|
||||
expect(response).to.have.property('mutedInfo').that.is.a('object');
|
||||
const { mutedInfo } = response;
|
||||
expect(mutedInfo).to.deep.eq({
|
||||
muted: true,
|
||||
reason: 'user'
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -42,6 +42,13 @@ const handleRequest = (request, sender, sendResponse) => {
|
|||
chrome.tabs.reload(tabId).then(() => {
|
||||
sendResponse({ status: 'reloaded' });
|
||||
});
|
||||
break;
|
||||
}
|
||||
|
||||
case 'update': {
|
||||
const [params] = args;
|
||||
chrome.tabs.update(tabId, params).then(sendResponse);
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -34,6 +34,11 @@ const testMap = {
|
|||
chrome.runtime.sendMessage({ method: 'reload' }, response => {
|
||||
console.log(JSON.stringify(response));
|
||||
});
|
||||
},
|
||||
update (params) {
|
||||
chrome.runtime.sendMessage({ method: 'update', args: [params] }, response => {
|
||||
console.log(JSON.stringify(response));
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue