File: indexed-browsing-contexts-01.html

package info (click to toggle)
firefox 144.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 4,637,504 kB
  • sloc: cpp: 7,576,692; javascript: 6,430,831; ansic: 3,748,119; python: 1,398,978; xml: 628,810; asm: 438,679; java: 186,194; sh: 63,212; makefile: 19,159; objc: 13,086; perl: 12,986; yacc: 4,583; cs: 3,846; pascal: 3,448; lex: 1,720; ruby: 1,003; exp: 762; php: 436; lisp: 258; awk: 247; sql: 66; sed: 53; csh: 10
file content (47 lines) | stat: -rw-r--r-- 2,211 bytes parent folder | download | duplicates (38)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<!DOCTYPE html>
<meta charset="utf-8">
<title>HTML Test: the browsing contexts must be sorted in the order that their containers were inserted into the Document</title>
<link rel="author" title="Intel" href="http://www.intel.com/" />
<link rel="help" href="https://html.spec.whatwg.org/multipage/multipage/browsers.html#accessing-other-browsing-contexts" />
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<div id="log"></div>
<script>

var t1 = async_test("The window's length must return the number of child browsing contexts(in iframe)");
function on_load1(fr) {
  t1.step(function () {
    var doc = fr.contentDocument;
    var fr3 = doc.createElement("iframe");
    fr3.setAttribute("id", "fr3");
    doc.body.insertBefore(fr3, doc.getElementById("tbl"));

    assert_equals(fr.contentWindow.length, 3, "The window.length should be 3.");
    assert_array_equals([fr.contentWindow[0].frameElement, fr.contentWindow[1].frameElement, fr.contentWindow[2].frameElement],
                        [fr.contentDocument.getElementById("fr4"), fr.contentDocument.getElementById("fr5"), fr.contentDocument.getElementById("fr3")],
                        "The child browsing contexts must be sorted in the order that their containers were inserted into the Document.");
  });
  t1.done();
}

var t2 = async_test("The window's length must return zero if it has no child browsing context");
function on_load2(fr) {
  t2.step(function () {
    assert_equals(fr.contentWindow.length, 0, "The window.length should be 0.");
  });
  t2.done();
}

</script>
<iframe id="fr1" src="test1.html" style="display:none" onload="on_load1(this)"></iframe>
<iframe id="fr2" src="test2.html" style="display:none" onload="on_load2(this)"></iframe>
<script>

test(function () {
  assert_equals(window.length, 2, "The window.length should be 2.");
  assert_array_equals([window[0].frameElement, window[1].frameElement],
                      [document.getElementById("fr1"), document.getElementById("fr2")],
                     "The child browsing contexts must be sorted in the tree order.");
}, "The window's length must return the number of child browsing contexts");

</script>