Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: third_party/WebKit/LayoutTests/fast/dom/Window/lookup-behavior.html

Issue 2452073002: Freeze global prototype chain per WebIDL (Closed)
Patch Set: Test improvements Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/fast/dom/Window/script-tests/window-custom-prototype.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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>
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/fast/dom/Window/script-tests/window-custom-prototype.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698