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

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

Issue 1282223003: bindings: Adds a layout test to check Window's name look-up behavior. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 4 months 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | LayoutTests/fast/dom/Window/lookup-behavior-expected.txt » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <title></title>
3 <script src="../../../resources/testharness.js"></script>
4 <script src="../../../resources/testharnessreport.js"></script>
5 <div id="container"></div>
6 <script>
7 var global = this;
8 var container = document.getElementById('container');
9
10 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.
11 var originalAlert = window.alert;
12 var iframe = document.createElement('iframe');
13 iframe.name = 'alert';
14 container.appendChild(iframe);
15 assert_equals(window.alert, originalAlert, "window.alert shouldn't be shadow ed by named properties.");
16 }, "Named access test. Window's members should have priority over named propert ies.");
17
18 test(function() {
19 // Window's prototype chain must be
20 // window --> Window.prototype --> "WindowProperties" --> EventTarget.protot ype
21 assert_equals(window.__proto__, Window.prototype);
22 assert_class_string(window.__proto__.__proto__, 'WindowProperties');
23 assert_equals(window.__proto__.__proto__.__proto__, EventTarget.prototype);
24 }, "WindowProperties object should exist.");
25
26 test(function() {
27 var anchor = document.createElement('a');
28 anchor.id = 'myAnchor';
29 container.appendChild(anchor);
30 assert_equals(window.myAnchor, anchor, "Named access should work when Window Properties is available.");
31 // Remove the WindowProperties object from the prototype chain. This means,
32 // 'window' no longer supports named access.
33 Window.prototype.__proto__ = EventTarget.prototype;
34 assert_equals(window.myAnchor, undefined, "Named access shouldn't work when WindowProperties is not available.");
35 }, "WindowProperties object should provide named access.");
36
37 test(function() {
38 assert_true(window.hasOwnProperty('onclick'), "Window's event handlers shoul d be own properties.");
39 assert_true(window.hasOwnProperty('alert'), "Window's methods should be own properties.");
40 }, "Window's members should be own members.");
41
42 // This test needs to run in the global scope.
43 assert_equals(window.onclick, null, "window.onclick is not yet set.");
44 var wasMyOnClickCalled = false;
45 var myOnClick = function() { wasMyOnClickCalled = true; };
46 var onclick = myOnClick;
47 assert_equals(window.onclick, myOnClick, "var declaration should be ignored, and window.onclick should be updated.");
48 window.dispatchEvent(new Event('click'));
49 assert_true(wasMyOnClickCalled, "myOnClick should have been called.");
50 </script>
51 </html>
OLDNEW
« no previous file with comments | « no previous file | LayoutTests/fast/dom/Window/lookup-behavior-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698