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

Side by Side Diff: LayoutTests/imported/web-platform-tests/html/browsers/the-window-object/window-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>Properties of the window object</title>
4 <link rel="author" title="Ms2ger" href="mailto:Ms2ger@gmail.com">
5 <link rel="help" href="http://ecma-international.org/ecma-262/5.1/#sec-15.1">
6 <link rel="help" href="https://heycam.github.io/webidl/#interface-prototype-obje ct">
7 <link rel="help" href="https://heycam.github.io/webidl/#es-attributes">
8 <link rel="help" href="https://heycam.github.io/webidl/#es-operations">
9 <link rel="help" href="https://dom.spec.whatwg.org/#eventtarget">
10 <link rel="help" href="https://html.spec.whatwg.org/multipage/#window">
11 <link rel="help" href="https://html.spec.whatwg.org/multipage/#windowtimers">
12 <link rel="help" href="https://html.spec.whatwg.org/multipage/#windowbase64">
13 <link rel="help" href="https://html.spec.whatwg.org/multipage/#windowsessionstor age">
14 <link rel="help" href="https://html.spec.whatwg.org/multipage/#windowlocalstorag e">
15 <link rel="help" href="https://dvcs.w3.org/hg/editing/raw-file/tip/editing.html# dom-window-getselection">
16 <link rel="help" href="http://dev.w3.org/csswg/cssom/#widl-def-Window">
17 <link rel="help" href="http://dev.w3.org/csswg/cssom-view/#widl-def-Window">
18 <script src="../../../../../resources/testharness.js"></script>
19 <script src="../../../../../resources/testharnessreport.js"></script>
20 <div id=log></div>
21 <script>
22 function assert_data_propdesc(pd, Writable, Enumerable, Configurable) {
23 assert_equals(typeof pd, "object");
24 assert_equals(pd.writable, Writable);
25 assert_equals(pd.enumerable, Enumerable);
26 assert_equals(pd.configurable, Configurable);
27 }
28 function assert_accessor_propdesc(pd, hasSetter, Enumerable, Configurable) {
29 assert_equals(typeof pd, "object");
30 assert_equals(typeof pd.get, "function");
31 assert_true("set" in pd,
32 "Should always have a setter property on the property descriptor") ;
33 assert_equals(typeof pd.set, hasSetter ? "function" : "undefined");
34 assert_equals(pd.enumerable, Enumerable);
35 assert_equals(pd.configurable, Configurable);
36 }
37
38 var unforgeableAttributes = [
39 "window",
40 "document",
41 "location",
42 "top"
43 ];
44
45 var replaceableAttributes = [
46 "self",
47 "locationbar",
48 "menubar",
49 "personalbar",
50 "scrollbars",
51 "statusbar",
52 "toolbar",
53 "frames",
54 "parent",
55 "external",
56 "length",
57
58 // CSSOM-View
59 "screen",
60 "scrollX",
61 "scrollY",
62 "pageXOffset",
63 "pageYOffset",
64 "innerWidth",
65 "innerHeight",
66 "screenX",
67 "screenY",
68 "outerWidth",
69 "outerHeight",
70 "devicePixelRatio",
71 ];
72
73 var methods = [
74 "close",
75 "stop",
76 "focus",
77 "blur",
78 "open",
79 "alert",
80 "confirm",
81 "prompt",
82 "print",
83 // See below: "showModalDialog",
84 "postMessage",
85
86 // WindowBase64
87 "btoa",
88 "atob",
89
90 // WindowTimers
91 "setTimeout",
92 "clearTimeout",
93 "setInterval",
94 "clearInterval",
95
96 // HTML Editing APIs
97 "getSelection",
98
99 // CSSOM
100 "getComputedStyle",
101
102 // CSSOM-View
103 "matchMedia",
104 "scroll",
105 "scrollTo",
106 "scrollBy"
107 ];
108
109 // We would like to remove showModalDialog from the platform,
110 // see <https://www.w3.org/Bugs/Public/show_bug.cgi?id=26437>.
111 if ("showModalDialog" in window) {
112 methods.push("showModalDialog");
113 }
114
115 var readonlyAttributes = [
116 "history",
117 "frameElement",
118 "navigator",
119 "applicationCache",
120
121 // WindowSessionStorage
122 "sessionStorage",
123
124 // WindowLocalStorage
125 "localStorage",
126 ];
127
128 var writableAttributes = [
129 "name",
130 "status",
131 "opener",
132 "onabort",
133 "onafterprint",
134 "onbeforeprint",
135 "onbeforeunload",
136 "onblur",
137 "oncancel",
138 "oncanplay",
139 "oncanplaythrough",
140 "onchange",
141 "onclick",
142 "onclose",
143 "oncontextmenu",
144 "oncuechange",
145 "ondblclick",
146 "ondrag",
147 "ondragend",
148 "ondragenter",
149 "ondragleave",
150 "ondragover",
151 "ondragstart",
152 "ondrop",
153 "ondurationchange",
154 "onemptied",
155 "onended",
156 "onerror",
157 "onfocus",
158 "onhashchange",
159 "oninput",
160 "oninvalid",
161 "onkeydown",
162 "onkeypress",
163 "onkeyup",
164 "onload",
165 "onloadeddata",
166 "onloadedmetadata",
167 "onloadstart",
168 "onmessage",
169 "onmousedown",
170 "onmousemove",
171 "onmouseout",
172 "onmouseover",
173 "onmouseup",
174 "onmousewheel",
175 "onoffline",
176 "ononline",
177 "onpause",
178 "onplay",
179 "onplaying",
180 "onpagehide",
181 "onpageshow",
182 "onpopstate",
183 "onprogress",
184 "onratechange",
185 "onreset",
186 "onresize",
187 "onscroll",
188 "onseeked",
189 "onseeking",
190 "onselect",
191 "onshow",
192 "onstalled",
193 "onstorage",
194 "onsubmit",
195 "onsuspend",
196 "ontimeupdate",
197 "onunload",
198 "onvolumechange",
199 "onwaiting"
200 ];
201
202 test(function() {
203 // 15.1.1 Value Properties of the Global Object
204 ["NaN", "Infinity", "undefined"].forEach(function(id) {
205 test(function() {
206 assert_true(id in window, id + " in window");
207 assert_data_propdesc(Object.getOwnPropertyDescriptor(window, id),
208 false, false, false);
209 }, "Value Property: " + id);
210 });
211 }, "Value Properties of the Global Object");
212 test(function() {
213 // 15.1.2 Function Properties of the Global Object
214 ["eval", "parseInt", "parseFloat", "isNaN", "isFinite"].forEach(function(id) {
215 test(function() {
216 assert_true(id in window, id + " in window");
217 assert_data_propdesc(Object.getOwnPropertyDescriptor(window, id),
218 true, false, true);
219 }, "Function Property: " + id);
220 });
221 }, "Function Properties of the Global Object");
222 test(function() {
223 // 15.1.3 URI Handling Function Properties
224 ["decodeURI", "decodeURIComponent", "encodeURI", "encodeURIComponent"].forEach (function(id) {
225 test(function() {
226 assert_true(id in window, id + " in window");
227 assert_data_propdesc(Object.getOwnPropertyDescriptor(window, id),
228 true, false, true);
229 }, "URI Handling Function Property: " + id);
230 });
231 }, "URI Handling Function Properties");
232 test(function() {
233 // 15.1.4 Constructor Properties of the Global Object
234 ["Object", "Function", "Array", "String", "Boolean", "Number", "Date",
235 "RegExp", "Error", "EvalError", "RangeError", "ReferenceError",
236 "SyntaxError", "TypeError", "URIError"].forEach(function(id) {
237 test(function() {
238 assert_true(id in window, id + " in window");
239 assert_data_propdesc(Object.getOwnPropertyDescriptor(window, id),
240 true, false, true);
241 }, "Constructor Property: " + id);
242 });
243 }, "Constructor Properties of the Global Object");
244 test(function() {
245 // 15.1.5 Other Properties of the Global Object
246 ["Math", "JSON"].forEach(function(id) {
247 test(function() {
248 assert_true(id in window, id + " in window");
249 assert_data_propdesc(Object.getOwnPropertyDescriptor(window, id),
250 true, false, true);
251 }, "Other Property: " + id);
252 });
253 }, "Other Properties of the Global Object");
254 test(function() {
255 // EventTarget interface
256 ["addEventListener", "removeEventListener", "dispatchEvent"].forEach(function( id) {
257 test(function() {
258 var EventTargetProto = EventTarget.prototype;
259 assert_true(id in window, id + " in window");
260 assert_equals(window[id], EventTargetProto[id]);
261 assert_data_propdesc(Object.getOwnPropertyDescriptor(EventTargetProto, id) ,
262 true, true, true);
263 assert_equals(Object.getOwnPropertyDescriptor(window, id), undefined);
264 }, "EventTarget method: " + id);
265 });
266 }, "EventTarget interface");
267 test(function() {
268 // Window interface
269 methods.forEach(function(id) {
270 test(function() {
271 var WindowProto = Window.prototype;
272 assert_true(id in window, id + " in window");
273 assert_false(id in WindowProto, id + " in Window.prototype");
274 assert_data_propdesc(Object.getOwnPropertyDescriptor(window, id),
275 true, true, true);
276 }, "Window method: " + id);
277 });
278 readonlyAttributes.forEach(function(id) {
279 test(function() {
280 var WindowProto = Window.prototype;
281 assert_true(id in window, id + " in window");
282 assert_false(id in WindowProto, id + " in Window.prototype");
283 assert_accessor_propdesc(Object.getOwnPropertyDescriptor(window, id),
284 false, true, true);
285 }, "Window readonly attribute: " + id);
286 });
287 writableAttributes.forEach(function(id) {
288 test(function() {
289 var WindowProto = Window.prototype;
290 assert_true(id in window, id + " in window");
291 assert_false(id in WindowProto, id + " in Window.prototype");
292 assert_accessor_propdesc(Object.getOwnPropertyDescriptor(window, id),
293 true, true, true);
294 }, "Window attribute: " + id);
295 });
296 unforgeableAttributes.forEach(function(id) {
297 test(function() {
298 var WindowProto = Window.prototype;
299 assert_true(id in window, id + " in window");
300 assert_false(id in WindowProto, id + " in Window.prototype");
301 // location has a [PutForwards] extended attribute.
302 assert_accessor_propdesc(Object.getOwnPropertyDescriptor(window, id),
303 id === "location", true, false);
304 }, "Window unforgeable attribute: " + id);
305 });
306 replaceableAttributes.forEach(function(id) {
307 test(function() {
308 var WindowProto = Window.prototype;
309 assert_true(id in window, id + " in window");
310 assert_false(id in WindowProto, id + " in Window.prototype");
311 assert_accessor_propdesc(Object.getOwnPropertyDescriptor(window, id),
312 true, true, true);
313 }, "Window replaceable attribute: " + id);
314 });
315 }, "Window interface");
316 test(function() {
317 assert_equals(window.constructor, Window);
318 assert_false(window.hasOwnProperty("constructor"), "window.constructor should not be an own property.");
319 assert_data_propdesc(Object.getOwnPropertyDescriptor(Window.prototype, "constr uctor"),
320 true, false, true);
321 }, "constructor");
322 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698