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

Unified 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: Addressed review comments. 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | LayoutTests/fast/dom/Window/lookup-behavior-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..f95904c853a87287115e9ca29d5638635deac758
--- /dev/null
+++ b/LayoutTests/fast/dom/Window/lookup-behavior.html
@@ -0,0 +1,52 @@
+<!DOCTYPE html>
+<title>Name look-up tests of Window interface</title>
+<!-- TODO(yukishiino): Change the name look-up behavior of Window and fix all these tests. -->
+<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() {
+ 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_false(!!window.onclick, "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>
« 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