mirror of
https://github.com/HeyPuter/firefox.git
synced 2026-11-25 02:40:22 -10:00
This is an autogenerated commit to handle scripts loading mochitest harness files, in the simple case where the script src is on the same line as the tag. This was generated with https://bug1544322.bmoattachments.org/attachment.cgi?id=9058170 using the `--part 1` argument. Differential Revision: https://phabricator.services.mozilla.com/D26812
82 lines
2.2 KiB
HTML
82 lines
2.2 KiB
HTML
<!DOCTYPE HTML>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="utf8">
|
|
<title>Test for the Console API and Workers</title>
|
|
<script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
|
|
<script type="text/javascript" src="common.js"></script>
|
|
<!-- Any copyright is dedicated to the Public Domain.
|
|
- http://creativecommons.org/publicdomain/zero/1.0/ -->
|
|
</head>
|
|
<body>
|
|
<p>Test for the Console API and Workers</p>
|
|
|
|
<script class="testbody" type="text/javascript">
|
|
SimpleTest.waitForExplicitFinish();
|
|
|
|
let expectedCachedConsoleCalls = [
|
|
{
|
|
level: "log",
|
|
filename: /console-test-worker/,
|
|
arguments: ['Log from worker init'],
|
|
},
|
|
];
|
|
|
|
let expectedConsoleAPICalls = [
|
|
{
|
|
level: "log",
|
|
arguments: ['Log was requested from worker'],
|
|
},
|
|
];
|
|
|
|
window.onload = async function () {
|
|
let {state,response} = await new Promise(resolve => {
|
|
attachConsoleToWorker(["ConsoleAPI"], (state, response) => {
|
|
resolve({state,response})
|
|
});
|
|
});
|
|
|
|
await testCachedMessages(state);
|
|
await testConsoleAPI(state);
|
|
|
|
closeDebugger(state, function() {
|
|
SimpleTest.finish();
|
|
});
|
|
};
|
|
|
|
let testCachedMessages = async function (state) {
|
|
info("testCachedMessages entered");
|
|
return new Promise(resolve => {
|
|
let onCachedConsoleAPI = (response) => {
|
|
let consoleCalls = response.messages;
|
|
|
|
info('Received cached response. Checking console calls.');
|
|
checkConsoleAPICalls(consoleCalls, expectedCachedConsoleCalls);
|
|
resolve();
|
|
};
|
|
state.client.getCachedMessages(["ConsoleAPI"]).then(onCachedConsoleAPI);
|
|
})
|
|
};
|
|
|
|
let testConsoleAPI = async function (state) {
|
|
info("testConsoleAPI entered");
|
|
return new Promise(resolve => {
|
|
let onConsoleAPICall = (packet) => {
|
|
info("received message level: " + packet.message.level);
|
|
checkConsoleAPICalls([packet.message], expectedConsoleAPICalls);
|
|
state.client.off("consoleAPICall", onConsoleAPICall);
|
|
resolve();
|
|
}
|
|
|
|
info("testConsoleAPI: adding listener for consoleAPICall");
|
|
state.client.on("consoleAPICall", onConsoleAPICall);
|
|
|
|
state.client.evaluateJS("console.log('Log was requested from worker')",
|
|
() => { });
|
|
});
|
|
};
|
|
|
|
</script>
|
|
</body>
|
|
</html>
|