OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <title>Name look-up tests of Window interface</title> | 2 <title>Name look-up tests of Window interface</title> |
3 <!-- TODO(yukishiino): Change the name look-up behavior of Window and fix all th
ese tests. --> | 3 <!-- TODO(yukishiino): Change the name look-up behavior of Window and fix all th
ese tests. --> |
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 <div id="container"></div> | 6 <div id="container"></div> |
7 <script> | 7 <script> |
8 var global = this; | 8 var global = this; |
9 var container = document.getElementById('container'); | 9 var container = document.getElementById('container'); |
10 | 10 |
(...skipping 11 matching lines...) Expand all Loading... |
22 assert_equals(window.__proto__, Window.prototype); | 22 assert_equals(window.__proto__, Window.prototype); |
23 assert_class_string(window.__proto__.__proto__, 'WindowProperties'); | 23 assert_class_string(window.__proto__.__proto__, 'WindowProperties'); |
24 assert_equals(window.__proto__.__proto__.__proto__, EventTarget.prototype); | 24 assert_equals(window.__proto__.__proto__.__proto__, EventTarget.prototype); |
25 }, "WindowProperties object should exist."); | 25 }, "WindowProperties object should exist."); |
26 | 26 |
27 test(function() { | 27 test(function() { |
28 var anchor = document.createElement('a'); | 28 var anchor = document.createElement('a'); |
29 anchor.id = 'myAnchor'; | 29 anchor.id = 'myAnchor'; |
30 container.appendChild(anchor); | 30 container.appendChild(anchor); |
31 assert_equals(window.myAnchor, anchor, "Named access should work when Window
Properties is available."); | 31 assert_equals(window.myAnchor, anchor, "Named access should work when Window
Properties is available."); |
32 // Remove the WindowProperties object from the prototype chain. This means, | 32 // Look up the prototype chain and observe that the anchor is defined on the |
33 // 'window' no longer supports named access. | 33 // named properties object, no lower or higher. |
34 Window.prototype.__proto__ = EventTarget.prototype; | 34 assert_equals(window.__proto__.myAnchor, anchor, "Named access should work o
n Window.prototype"); |
35 assert_equals(window.myAnchor, undefined, "Named access shouldn't work when
WindowProperties is not available."); | 35 assert_equals(window.__proto__.__proto__.myAnchor, anchor, "Named access sho
uld work on named properties object"); |
| 36 assert_equals(window.__proto__.__proto__.__proto__.myAnchor, undefined, "Nam
ed access does not work on EventTarget.prototype"); |
| 37 assert_equals(window.__proto__.__proto__.__proto__.__proto__.myAnchor, undef
ined, "Named access does not work on Object.prototype"); |
36 }, "WindowProperties object should provide named access."); | 38 }, "WindowProperties object should provide named access."); |
37 | 39 |
38 test(function() { | 40 test(function() { |
39 assert_true(window.hasOwnProperty('onclick'), "Window's event handlers shoul
d be own properties."); | 41 assert_true(window.hasOwnProperty('onclick'), "Window's event handlers shoul
d be own properties."); |
40 assert_true(window.hasOwnProperty('alert'), "Window's methods should be own
properties."); | 42 assert_true(window.hasOwnProperty('alert'), "Window's methods should be own
properties."); |
41 }, "Window's members should be own members."); | 43 }, "Window's members should be own members."); |
42 | 44 |
43 // This test needs to run in the global scope. | 45 // This test needs to run in the global scope. |
44 assert_false(!!window.onclick, "window.onclick is not yet set."); | 46 assert_false(!!window.onclick, "window.onclick is not yet set."); |
45 var wasMyOnClickCalled = false; | 47 var wasMyOnClickCalled = false; |
46 var myOnClick = function() { wasMyOnClickCalled = true; }; | 48 var myOnClick = function() { wasMyOnClickCalled = true; }; |
47 var onclick = myOnClick; | 49 var onclick = myOnClick; |
48 assert_equals(window.onclick, myOnClick, "var declaration should be ignored, and
window.onclick should be updated."); | 50 assert_equals(window.onclick, myOnClick, "var declaration should be ignored, and
window.onclick should be updated."); |
49 window.dispatchEvent(new Event('click')); | 51 window.dispatchEvent(new Event('click')); |
50 assert_true(wasMyOnClickCalled, "myOnClick should have been called."); | 52 assert_true(wasMyOnClickCalled, "myOnClick should have been called."); |
51 </script> | 53 </script> |
52 </html> | 54 </html> |
OLD | NEW |