summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/html/browsers/the-window-object/accessing-other-browsing-contexts/indexed-browsing-contexts-02.html
blob: d09c944fd84dba7ceb49a6b6c7b07538c9ab1941 (plain)
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<!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>