blob: 3f2a4fe90f87280032487ef6796269714269f552 [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<script src="../../http/tests/inspector/resources/inspector-test.js"></script>
<script>
function test()
{
let suite = InspectorTest.createAsyncSuite("Page.setBootstrapScript");
suite.addTestCase({
name: "Page.setBootstrapScript.MainFrame",
description: "Test that the bootstrap script is executed in the main frame.",
async test() {
InspectorTest.assert(!WI.networkManager.bootstrapScript, "Should not already have a bootstrap script.");
let valueBeforeBootstrapScript = await InspectorTest.evaluateInPage(`window.valueFromBootstrapScript`);
InspectorTest.expectEqual(valueBeforeBootstrapScript, undefined, "'valueFromBootstrapScript' should be 'undefined'.");
InspectorTest.log("Setting bootstrap script...");
await WI.networkManager.createBootstrapScript(`window.valueFromBootstrapScript = 42;`);
WI.networkManager.bootstrapScriptEnabled = true;
InspectorTest.log("Reloading page...");
await Promise.all([
InspectorTest.awaitEvent(FrontendTestHarness.Event.TestPageDidLoad),
InspectorTest.reloadPage(),
]);
let valueAfterBootstrapScript = await InspectorTest.evaluateInPage(`window.valueFromBootstrapScript`);
InspectorTest.expectEqual(valueAfterBootstrapScript, 42, "'valueFromBootstrapScript' should be '42'.");
},
});
suite.runTestCasesAndFinish();
}
</script>
</head>
<body onload="runTest()">
<p>Tests for Page.setBootstrapScript command.</p>
</body>
</html>