blob: 660a98899322ff27cf10f796b353dfa0c18de092 [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 can access a named element in a same-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:");
shouldNotBe("frame.contentDocument.getElementById('A')", "elementAInInactiveDocument");
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://127.0.0.1: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>