blob: 7a733378d2d7ed69a768d436c73fc6aae6428861 [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<script src="/js-test-resources/js-test-pre.js"></script>
<script>
window.jsTestIsAsync = true;
</script>
</head>
<body>
<script>
description("This tests that an inactive document cannot access a named element in a cross-origin active document.");
var frame = document.body.appendChild(document.createElement("iframe")); // Loads about:blank
var frameDocument = frame.contentDocument;
var elementAInInactiveDocument = frameDocument.createElement("div");
elementAInInactiveDocument.id = "A";
frameDocument.body.appendChild(elementAInInactiveDocument);
var elementAInDetachedWindowFunction = frame.contentWindow.Function("return A;");
var elementBInDetachedWindowFunction = frame.contentWindow.Function("return B;");
frame.onload = function ()
{
debug("Lookup named element whose name corresponds to an element in the initial about:blank document:")
shouldBe("elementAInDetachedWindowFunction()", 'elementAInInactiveDocument');
debug("<br>Lookup named element whose name does not correspond to an element in the initial about:blank document:");
shouldThrowErrorName("elementBInDetachedWindowFunction()", 'ReferenceError');
finishJSTest();
}
frame.src = "http://localhost:8000/security/resources/innocent-victim-with-named-elements.html"; // about:blank becomes the inactive document
</script>
<script src="/js-test-resources/js-test-post.js"></script>
</body>
</html>