Chromium Code Reviews| Index: LayoutTests/fast/dom/Window/lookup-behavior.html |
| diff --git a/LayoutTests/fast/dom/Window/lookup-behavior.html b/LayoutTests/fast/dom/Window/lookup-behavior.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..a47b756a6858013e105fbd9f6813feddddbdc6a6 |
| --- /dev/null |
| +++ b/LayoutTests/fast/dom/Window/lookup-behavior.html |
| @@ -0,0 +1,51 @@ |
| +<!DOCTYPE html> |
| +<title></title> |
| +<script src="../../../resources/testharness.js"></script> |
| +<script src="../../../resources/testharnessreport.js"></script> |
| +<div id="container"></div> |
| +<script> |
| +var global = this; |
| +var container = document.getElementById('container'); |
| + |
| +test(function() { |
|
haraken
2015/08/11 07:00:52
Shall we add TODO(yukishiino) and mention that the
Yuki
2015/08/12 04:51:49
Done.
|
| + var originalAlert = window.alert; |
| + var iframe = document.createElement('iframe'); |
| + iframe.name = 'alert'; |
| + container.appendChild(iframe); |
| + assert_equals(window.alert, originalAlert, "window.alert shouldn't be shadowed by named properties."); |
| +}, "Named access test. Window's members should have priority over named properties."); |
| + |
| +test(function() { |
| + // Window's prototype chain must be |
| + // window --> Window.prototype --> "WindowProperties" --> EventTarget.prototype |
| + assert_equals(window.__proto__, Window.prototype); |
| + assert_class_string(window.__proto__.__proto__, 'WindowProperties'); |
| + assert_equals(window.__proto__.__proto__.__proto__, EventTarget.prototype); |
| +}, "WindowProperties object should exist."); |
| + |
| +test(function() { |
| + var anchor = document.createElement('a'); |
| + anchor.id = 'myAnchor'; |
| + container.appendChild(anchor); |
| + assert_equals(window.myAnchor, anchor, "Named access should work when WindowProperties is available."); |
| + // Remove the WindowProperties object from the prototype chain. This means, |
| + // 'window' no longer supports named access. |
| + Window.prototype.__proto__ = EventTarget.prototype; |
| + assert_equals(window.myAnchor, undefined, "Named access shouldn't work when WindowProperties is not available."); |
| +}, "WindowProperties object should provide named access."); |
| + |
| +test(function() { |
| + assert_true(window.hasOwnProperty('onclick'), "Window's event handlers should be own properties."); |
| + assert_true(window.hasOwnProperty('alert'), "Window's methods should be own properties."); |
| +}, "Window's members should be own members."); |
| + |
| +// This test needs to run in the global scope. |
| +assert_equals(window.onclick, null, "window.onclick is not yet set."); |
| +var wasMyOnClickCalled = false; |
| +var myOnClick = function() { wasMyOnClickCalled = true; }; |
| +var onclick = myOnClick; |
| +assert_equals(window.onclick, myOnClick, "var declaration should be ignored, and window.onclick should be updated."); |
| +window.dispatchEvent(new Event('click')); |
| +assert_true(wasMyOnClickCalled, "myOnClick should have been called."); |
| +</script> |
| +</html> |