Source code

Revision control

Copy as Markdown

Other Tools

Test Info: Warnings

  • This test has a WPT meta file that expects 1 subtest issues.
  • This WPT test may be referenced by the following Test IDs:
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<title>HTML Test: the browsing contexts created by various container elements</title>
<link rel="author" title="Intel" href="http://www.intel.com/" />
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
var t1 = async_test("Accessing child browsing contexts 1");
var t2 = async_test("Accessing child browsing contexts 2");
var t3 = async_test("Accessing child browsing contexts 3");
function on_load() {
//Child browsing contexts created by iframe, object and embed elements.
t1.step(function () {
assert_equals(window.length, 3, "The top browsing context should have 3 child browsing contexts.");
});
t1.step(function () {
assert_equals(window[0].name, "win1", "The browsing context name should be 'win1'.");
assert_equals(window[1].name, "win2", "The browsing context name should be 'win2'.");
assert_equals(window[2].name, "win3", "The browsing context name should be 'win3'.");
});
t1.done();
//Child browsing contexts created by frame elements.
t2.step(function () {
assert_equals(document.getElementById("fr").contentWindow.length, 2,
"The child browsing context created by the iframe element should have 2 child browsing contexts.");
});
t2.step(function () {
assert_equals(document.getElementById("fr").contentWindow[0].name, "win4",
"The browsing context name should be 'win4'.");
assert_equals(document.getElementById("fr").contentWindow[1].name, "win5",
"The browsing context name should be 'win5'.");
});
t2.done();
//The child browsing context will be removed if the data attribute of the associated object element is removed.
t3.step(function () {
document.getElementById("obj").removeAttribute("type");
assert_equals(window.length, 3, "The top browsing context should have 3 child browsing contexts.");
document.getElementById("obj").removeAttribute("data");
assert_equals(window.length, 3, "The top browsing context should have 3 child browsing contexts.");
setTimeout(function () {
assert_equals(window.length, 2, "The top browsing context should have 2 child browsing contexts.");
}, 1);
});
t3.done();
}
</script>
</head>
<body onload="on_load()">
<div id="log"></div>
<div style="display:none">
<iframe id="fr" name="win1" src="test3.html"></iframe>
<object id="obj" name="win2" type="text/html" data="about:blank"></object>
<object type="image/png" src="/images/green.png"></object>
<embed id="emb" name="win3" type="image/svg+xml" src="/images/green.svg"></embed>
</div>
</body>