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

Side by Side Diff: LayoutTests/imported/web-platform-tests/html/browsers/the-window-object/window-named-properties.html

Issue 1160513003: W3C Test: Import web-platform-tests/html/browsers (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: rebase, bug links Created 5 years, 6 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
OLDNEW
(Empty)
1 <!doctype html>
2 <meta charset=utf-8>
3 <title>Changes to named properties of the window object</title>
4 <link rel="author" title="Ms2ger" href="ms2ger@gmail.com">
5 <link rel="author" title="Boris Zbarsky" href="bzbarsky@mit.edu">
6 <link rel="help" href="https://html.spec.whatwg.org/multipage/#window">
7 <link rel="help" href="https://html.spec.whatwg.org/multipage/#dom-window-namedi tem">
8 <link rel="help" href="https://heycam.github.io/webidl/#named-properties-object" >
9 <script src="../../../../../resources/testharness.js"></script>
10 <script src="../../../../../resources/testharnessreport.js"></script>
11 <div id=log></div>
12 <iframe name="bar"></iframe>
13 <iframe name="constructor"></iframe>
14 <script>
15 function assert_data_propdesc(pd, Writable, Enumerable, Configurable) {
16 assert_equals(typeof pd, "object");
17 assert_equals(pd.writable, Writable);
18 assert_equals(pd.enumerable, Enumerable);
19 assert_equals(pd.configurable, Configurable);
20 }
21 test(function() {
22 assert_true("bar" in window, "bar not in window");
23 assert_equals(window["bar"],
24 document.getElementsByTagName("iframe")[0].contentWindow);
25 }, "Static name");
26 test(function() {
27 assert_true("bar" in Window.prototype, "bar in Window.prototype");
28 assert_false(Window.prototype.hasOwnProperty("bar"), "Window.prototype.hasOwnP roperty(\"bar\")");
29
30 var gsp = Object.getPrototypeOf(Object.getPrototypeOf(window));
31 assert_true("bar" in gsp, "bar in gsp");
32 assert_true(gsp.hasOwnProperty("bar"), "gsp.hasOwnProperty(\"bar\")");
33 assert_data_propdesc(Object.getOwnPropertyDescriptor(gsp, "bar"),
34 false, true, true);
35 }, "Static name on the prototype");
36 test(function() {
37 assert_equals(window.constructor, Window);
38 assert_false(window.hasOwnProperty("constructor"), "window.constructor should not be an own property.");
39
40 var proto = Object.getPrototypeOf(window);
41 assert_equals(proto.constructor, Window);
42 assert_true("constructor" in proto, "constructor in proto");
43 assert_data_propdesc(Object.getOwnPropertyDescriptor(proto, "constructor"),
44 true, false, true);
45
46 var gsp = Object.getPrototypeOf(proto);
47 assert_true("constructor" in gsp, "constructor in gsp");
48 assert_true(gsp.hasOwnProperty("constructor"), "gsp.hasOwnProperty(\"construct or\")");
49 assert_data_propdesc(Object.getOwnPropertyDescriptor(gsp, "constructor"),
50 false, true, true);
51 }, "constructor");
52 var t = async_test("Dynamic name")
53 var t2 = async_test("Ghost name")
54 t.step(function() {
55 var iframe = document.getElementsByTagName("iframe")[0];
56 iframe.setAttribute("src", "data:text/html,<script>window.name='foo'<\/script> ");
57 iframe.onload = function() {
58 t.step(function() {
59 assert_true("foo" in window, "foo not in window");
60 assert_equals(window["foo"], iframe.contentWindow);
61 });
62 t.done();
63 t2.step(function() {
64 assert_false("bar" in window, "bar still in window");
65 assert_equals(window["bar"], undefined);
66 });
67 t2.done();
68 };
69 });
70 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698