11 lines
601 B
JavaScript
11 lines
601 B
JavaScript
// Test-only content script: forwards page messages to the background hook.
|
|
// Injected by build-test-extension.sh into the fixture pages only.
|
|
window.addEventListener('message', event => {
|
|
if (event.source !== window || !event.data || event.data.tuTest !== true) return;
|
|
const { id, cmd, tabId, values, value, tabs, skipAudible } = event.data;
|
|
browser.runtime.sendMessage({ type: 'tu-test', cmd, tabId, values, value, tabs, skipAudible }).then(
|
|
value => window.postMessage({ tuResult: id, value }, '*'),
|
|
error => window.postMessage({ tuResult: id, error: String(error) }, '*')
|
|
);
|
|
});
|