blob: 2c729c0ce46090a8536318509a75ecf42e7425c2 [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() {
let valueBeforeBootstrapScript = await InspectorTest.evaluateInPage(`window.valueFromBootstrapScript`);
InspectorTest.expectEqual(valueBeforeBootstrapScript, undefined, "'valueFromBootstrapScript' should be 'undefined'.");
InspectorTest.log("Setting bootstrap script...");
await WI.networkManager.createBootstrapScript();
WI.networkManager.bootstrapScriptEnabled = true;
WI.networkManager.bootstrapScript.currentRevision.updateRevisionContent(`window.valueFromBootstrapScript = 42;`);
InspectorTest.log("Reloading page...");
await InspectorTest.reloadPage();
await Promise.delay(10);
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>