blob: ea191a6b0407b753dad5392031c1373dd7dc3ef1 [file] [log] [blame]
<html>
<head>
<script src="../../resources/js-test.js"></script>
<script>
let isLoadComplete = false;
let wasChildFrameWasNavigated = false;
onload = () => {
isLoadComplete = true;
if (wasChildFrameWasNavigated)
runTest();
}
function childFrameWasNavigated()
{
wasChildFrameWasNavigated = true;
if (isLoadComplete)
runTest();
}
function runTest()
{
// Check that the child frame was unable to load a plugin, since its parent is sandboxed.
shouldBeTrue("(self.sandboxedFrame.frameWithPlugin.document.getElementById('plugin').destroyStream) == undefined");
// Check a non-sandboxed frame as well, to ensure that the plugin is disabled by sandboxing
// and not some other failure
shouldBeTrue("(self.frameWithPlugin.document.getElementById('plugin').destroyStream) != undefined");
// When the child frame (grandchild of the main window) has been navigated,
// make the sandboxed frame navigate itself
self.sandboxedFrame.location.assign("javascript: top.sandboxWasNavigated();");
}
function sandboxWasNavigated()
{
shouldBeEqualToString("String(document.getElementById('sandboxedFrameId').sandbox)", "allow-scripts allow-same-origin");
finishJSTest();
}
</script>
</head>
<body>
<iframe sandbox="allow-scripts allow-same-origin"
name="sandboxedFrame"
id="sandboxedFrameId"
src="resources/sandboxed-iframe-navigation-child.html">
</iframe>
<iframe name="frameWithPlugin"
src="resources/sandboxed-iframe-plugins-frame-object.html">
</iframe>
<script>
description("This test verifies that a sandboxed iframe CAN navigate both itself and a child in the frame tree. "
+ "It also verifies that the sandbox attribute remains intact after a frame has been navigated, "
+ "and that sandbox attributes are propagated through the frame hierarchy.");
jsTestIsAsync = true;
</script>
</body>
</html>