blob: f23b8c57aaa3eb6092e18f80147c938b9fb8e25e [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<script src="../../http/tests/inspector/resources/inspector-test.js"></script>
<script>
function addSubframe() {
let iframe = document.body.appendChild(document.createElement("iframe"));
iframe.src = "resources/bootstrap-iframe.html";
}
function test()
{
let suite = InspectorTest.createAsyncSuite("Page.setBootstrapScript");
suite.addTestCase({
name: "Page.setBootstrapScript.SubFrame",
description: "Test that the bootstrap script is executed in all sub frames.",
async test() {
InspectorTest.log("Setting bootstrap script...");
await WI.networkManager.createBootstrapScript();
WI.networkManager.bootstrapScriptEnabled = true;
WI.networkManager.bootstrapScript.currentRevision.updateRevisionContent(`window.valueFromBootstrapScript = 42;`);
InspectorTest.log("Adding subframe...");
let [valueFromBootstrapScriptEvent] = await Promise.all([
InspectorTest.awaitEvent("TestPage-subframe-valueFromBootstrapScript"),
WI.networkManager.awaitEvent(WI.NetworkManager.Event.FrameWasAdded),
InspectorTest.evaluateInPage(`addSubframe()`),
]);
InspectorTest.expectEqual(valueFromBootstrapScriptEvent.data, 42, "'valueFromBootstrapScript' should be '42'.");
},
});
suite.runTestCasesAndFinish();
}
</script>
</head>
<body onload="runTest()">
<p>Tests for Page.setBootstrapScript command.</p>
</body>
</html>