OLD | NEW |
1 <!doctype html> | 1 <!doctype html> |
2 <meta charset=utf-8> | 2 <meta charset=utf-8> |
3 <title>window.open() with "noopener" tests</title> | 3 <title>window.open() with "noopener" tests</title> |
4 <script src=/resources/testharness.js></script> | 4 <script src=/resources/testharness.js></script> |
5 <script src=/resources/testharnessreport.js></script> | 5 <script src=/resources/testharnessreport.js></script> |
6 <script> | 6 <script> |
7 var testData = [ | 7 var testData = [ |
8 { testDescription: "window.open() with 'noopener' should not reuse existing ta
rget", | 8 { testDescription: "window.open() with 'noopener' should not reuse existing ta
rget", |
9 secondWindowFeatureString: "noopener", | 9 secondWindowFeatureString: "noopener", |
10 shouldReuse: false }, | 10 shouldReuse: false }, |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 | 57 |
58 var w2 = window.open("", windowName, this.secondWindowFeatureString); | 58 var w2 = window.open("", windowName, this.secondWindowFeatureString); |
59 assert_equals(w2, w1); | 59 assert_equals(w2, w1); |
60 assert_equals(w2.opener, w1.opener); | 60 assert_equals(w2.opener, w1.opener); |
61 assert_equals(w2.opener, window); | 61 assert_equals(w2.opener, window); |
62 this.done(); | 62 this.done(); |
63 }); | 63 }); |
64 } else { | 64 } else { |
65 t.step(function() { | 65 t.step(function() { |
66 var w1; | 66 var w1; |
67 this.add_cleanup(function() { w1.close(); }); | 67 this.add_cleanup(function() { |
| 68 w1.close(); |
| 69 channel.postMessage(null); |
| 70 }); |
68 | 71 |
69 var windowName = this.windowName; | 72 var windowName = this.windowName; |
70 var channel = new BroadcastChannel(windowName); | 73 var channel = new BroadcastChannel(windowName); |
71 | 74 |
72 channel.onmessage = this.step_func_done(function(e) { | 75 channel.onmessage = this.step_func_done(function(e) { |
73 var data = e.data; | 76 var data = e.data; |
74 assert_equals(data.name, windowName, "Should have the right name"); | 77 assert_equals(data.name, windowName, "Should have the right name"); |
75 assert_equals(data.haveOpener, false, "Should not have opener"); | 78 assert_equals(data.haveOpener, false, "Should not have opener"); |
76 assert_equals(w1.opener, window); | 79 assert_equals(w1.opener, window); |
77 assert_equals(w1.location.href, "about:blank"); | 80 assert_equals(w1.location.href, "about:blank"); |
(...skipping 18 matching lines...) Expand all Loading... |
96 for (var target of ["_self", "_parent", "_top"]) { | 99 for (var target of ["_self", "_parent", "_top"]) { |
97 var t = async_test("noopener window.open targeting " + target); | 100 var t = async_test("noopener window.open targeting " + target); |
98 tests.push(t); | 101 tests.push(t); |
99 t.openedWindow = window.open(`javascript:var w2 = window.open("", "${target}",
"noopener"); this.checkValues(w2); this.close(); void(0);`); | 102 t.openedWindow = window.open(`javascript:var w2 = window.open("", "${target}",
"noopener"); this.checkValues(w2); this.close(); void(0);`); |
100 assert_equals(t.openedWindow.opener, window); | 103 assert_equals(t.openedWindow.opener, window); |
101 t.openedWindow.checkValues = t.step_func_done(function(win) { | 104 t.openedWindow.checkValues = t.step_func_done(function(win) { |
102 assert_equals(win, this.openedWindow); | 105 assert_equals(win, this.openedWindow); |
103 }); | 106 }); |
104 } | 107 } |
105 </script> | 108 </script> |
OLD | NEW |