wined3d: Pass a wined3d_device_context to wined3d_cs_emit_blt_sub_resource().
[wine/zf.git] / dlls / mshtml / tests / documentmode.js
blob75a132e83a7b620dbb7ceae47b9abb48a4ba4d9e
1 /*
2 * Copyright 2016 Jacek Caban for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 var compat_version;
20 var tests = [];
22 sync_test("elem_props", function() {
23 var elem = document.documentElement;
25 function test_exposed(prop, expect) {
26 if(expect)
27 ok(prop in elem, prop + " not found in element.");
28 else
29 ok(!(prop in elem), prop + " found in element.");
32 var v = document.documentMode;
34 test_exposed("doScroll", v < 11);
35 test_exposed("readyState", v < 11);
36 test_exposed("querySelectorAll", v >= 8);
37 test_exposed("textContent", v >= 9);
38 test_exposed("prefix", v >= 9);
39 test_exposed("firstElementChild", v >= 9);
40 test_exposed("onsubmit", v >= 9);
41 test_exposed("getElementsByClassName", v >= 9);
42 test_exposed("removeAttributeNS", v >= 9);
43 test_exposed("addEventListener", v >= 9);
44 test_exposed("removeEventListener", v >= 9);
45 test_exposed("dispatchEvent", v >= 9);
46 test_exposed("msSetPointerCapture", v >= 10);
47 if (v >= 9) test_exposed("spellcheck", v >= 10);
49 elem = document.createElement("style");
50 test_exposed("media", true);
51 test_exposed("type", true);
52 test_exposed("disabled", true);
53 test_exposed("media", true);
54 test_exposed("sheet", v >= 9);
55 test_exposed("readyState", v < 11);
56 test_exposed("styleSheet", v < 11);
57 });
59 sync_test("doc_props", function() {
60 function test_exposed(prop, expect) {
61 if(expect)
62 ok(prop in document, prop + " not found in document.");
63 else
64 ok(!(prop in document), prop + " found in document.");
67 var v = document.documentMode;
69 test_exposed("textContent", v >= 9);
70 test_exposed("prefix", v >= 9);
71 test_exposed("defaultView", v >= 9);
72 test_exposed("head", v >= 9);
73 test_exposed("addEventListener", v >= 9);
74 test_exposed("removeEventListener", v >= 9);
75 test_exposed("dispatchEvent", v >= 9);
76 test_exposed("createEvent", v >= 9);
78 test_exposed("parentWindow", true);
79 if(v >= 9) ok(document.defaultView === document.parentWindow, "defaultView != parentWindow");
80 });
82 sync_test("docfrag_props", function() {
83 var docfrag = document.createDocumentFragment();
85 function test_exposed(prop, expect) {
86 if(expect)
87 ok(prop in docfrag, prop + " not found in document fragent.");
88 else
89 ok(!(prop in docfrag), prop + " found in document fragent.");
92 var v = document.documentMode;
94 test_exposed("compareDocumentPosition", v >= 9);
95 });
97 sync_test("window_props", function() {
98 function test_exposed(prop, expect) {
99 if(expect)
100 ok(prop in window, prop + " not found in window.");
101 else
102 ok(!(prop in window), prop + " found in window.");
105 var v = document.documentMode;
107 test_exposed("postMessage", true);
108 test_exposed("sessionStorage", true);
109 test_exposed("localStorage", true);
110 test_exposed("addEventListener", v >= 9);
111 test_exposed("removeEventListener", v >= 9);
112 test_exposed("dispatchEvent", v >= 9);
113 test_exposed("getSelection", v >= 9);
114 test_exposed("onfocusout", v >= 9);
115 test_exposed("getComputedStyle", v >= 9);
116 if(v >= 9) /* FIXME: native exposes it in all compat modes */
117 test_exposed("performance", true);
120 sync_test("xhr_props", function() {
121 var xhr = new XMLHttpRequest();
123 function test_exposed(prop, expect) {
124 if(expect)
125 ok(prop in xhr, prop + " not found in XMLHttpRequest.");
126 else
127 ok(!(prop in xhr), prop + " found in XMLHttpRequest.");
130 var v = document.documentMode;
132 test_exposed("addEventListener", v >= 9);
133 test_exposed("removeEventListener", v >= 9);
134 test_exposed("dispatchEvent", v >= 9);
137 sync_test("stylesheet_props", function() {
138 var v = document.documentMode;
139 var elem = document.createElement("style");
140 document.body.appendChild(elem);
141 var sheet = v >= 9 ? elem.sheet : elem.styleSheet;
143 function test_exposed(prop, expect) {
144 if(expect)
145 ok(prop in sheet, prop + " not found in style sheet.");
146 else
147 ok(!(prop in sheet), prop + " found in style sheet.");
150 test_exposed("href", true);
151 test_exposed("title", true);
152 test_exposed("type", true);
153 test_exposed("media", true);
154 test_exposed("ownerNode", v >= 9);
155 test_exposed("ownerRule", v >= 9);
156 test_exposed("cssRules", v >= 9);
157 test_exposed("insertRule", v >= 9);
158 test_exposed("deleteRule", v >= 9);
159 test_exposed("disabled", true);
160 test_exposed("parentStyleSheet", true);
161 test_exposed("owningElement", true);
162 test_exposed("readOnly", true);
163 test_exposed("imports", true);
164 test_exposed("id", true);
165 test_exposed("addImport", true);
166 test_exposed("addRule", true);
167 test_exposed("removeImport", true);
168 test_exposed("removeRule", true);
169 test_exposed("cssText", true);
170 test_exposed("rules", true);
173 sync_test("xhr open", function() {
174 var e = false;
175 try {
176 (new XMLHttpRequest()).open("GET", "https://www.winehq.org/");
177 }catch(ex) {
178 e = true;
181 if(document.documentMode < 10)
182 ok(e, "expected exception");
183 else
184 ok(!e, "unexpected exception");
187 sync_test("style_props", function() {
188 var style = document.body.style;
190 function test_exposed(prop, expect) {
191 if(expect)
192 ok(prop in style, prop + " not found in style object.");
193 else
194 ok(!(prop in style), prop + " found in style object.");
197 var v = document.documentMode;
199 test_exposed("removeAttribute", true);
200 test_exposed("zIndex", true);
201 test_exposed("z-index", true);
202 test_exposed("filter", true);
203 test_exposed("pixelTop", true);
204 test_exposed("float", true);
205 test_exposed("css-float", false);
206 test_exposed("style-float", false);
207 test_exposed("setProperty", v >= 9);
208 test_exposed("removeProperty", v >= 9);
209 test_exposed("background-clip", v >= 9);
210 test_exposed("msTransform", v >= 9);
211 test_exposed("transform", v >= 10);
213 style = document.body.currentStyle;
215 test_exposed("zIndex", true);
216 test_exposed("z-index", true);
217 test_exposed("filter", true);
218 test_exposed("pixelTop", false);
219 test_exposed("float", true);
220 test_exposed("css-float", false);
221 test_exposed("style-float", false);
222 test_exposed("setProperty", v >= 9);
223 test_exposed("removeProperty", v >= 9);
224 test_exposed("background-clip", v >= 9);
225 test_exposed("transform", v >= 10);
227 if(window.getComputedStyle) {
228 style = window.getComputedStyle(document.body);
230 test_exposed("removeAttribute", false);
231 test_exposed("zIndex", true);
232 test_exposed("z-index", true);
233 test_exposed("pixelTop", false);
234 test_exposed("float", true);
235 test_exposed("css-float", false);
236 test_exposed("style-float", false);
237 test_exposed("setProperty", v >= 9);
238 test_exposed("removeProperty", v >= 9);
239 test_exposed("background-clip", v >= 9);
240 test_exposed("transform", v >= 10);
244 sync_test("JS objs", function() {
245 var g = window;
247 function test_exposed(func, obj, expect) {
248 if(expect)
249 ok(func in obj, func + " not found in " + obj);
250 else
251 ok(!(func in obj), func + " found in " + obj);
254 function test_parses(code, expect) {
255 var success;
256 try {
257 eval(code);
258 success = true;
259 }catch(e) {
260 success = false;
262 if(expect)
263 ok(success === true, code + " did not parse");
264 else
265 ok(success === false, code + " parsed");
268 var v = document.documentMode;
270 test_exposed("ScriptEngineMajorVersion", g, true);
272 test_exposed("JSON", g, v >= 8);
273 test_exposed("now", Date, true);
274 test_exposed("toISOString", Date.prototype, v >= 9);
275 test_exposed("isArray", Array, v >= 9);
276 test_exposed("forEach", Array.prototype, v >= 9);
277 test_exposed("indexOf", Array.prototype, v >= 9);
278 test_exposed("trim", String.prototype, v >= 9);
279 test_exposed("map", Array.prototype, v >= 9);
281 /* FIXME: IE8 implements weird semi-functional property descriptors. */
282 if(v != 8) {
283 test_exposed("getOwnPropertyDescriptor", Object, v >= 8);
284 test_exposed("defineProperty", Object, v >= 8);
285 test_exposed("defineProperties", Object, v >= 8);
288 test_exposed("getPrototypeOf", Object, v >= 9);
290 test_parses("if(false) { o.default; }", v >= 9);
291 test_parses("if(false) { o.with; }", v >= 9);
292 test_parses("if(false) { o.if; }", v >= 9);
295 sync_test("elem_by_id", function() {
296 document.body.innerHTML = '<form id="testid" name="testname"></form>';
298 var id_elem = document.getElementById("testid");
299 ok(id_elem.tagName === "FORM", "id_elem.tagName = " + id_elem.tagName);
301 var name_elem = document.getElementById("testname");
302 if(document.documentMode < 8)
303 ok(id_elem === name_elem, "id_elem != id_elem");
304 else
305 ok(name_elem === null, "name_elem != null");
308 sync_test("doc_mode", function() {
309 compat_version = parseInt(document.location.search.substring(1));
311 trace("Testing compatibility mode " + compat_version);
313 if(compat_version > 6 && compat_version > document.documentMode) {
314 win_skip("Document mode not supported (expected " + compat_version + " got " + document.documentMode + ")");
315 reportSuccess();
316 return;
319 ok(Math.max(compat_version, 5) === document.documentMode, "documentMode = " + document.documentMode);
321 if(document.documentMode > 5)
322 ok(document.compatMode === "CSS1Compat", "document.compatMode = " + document.compatMode);
323 else
324 ok(document.compatMode === "BackCompat", "document.compatMode = " + document.compatMode);
327 async_test("iframe_doc_mode", function() {
328 var iframe = document.createElement("iframe");
330 iframe.onload = function() {
331 var iframe_mode = iframe.contentWindow.document.documentMode;
332 if(document.documentMode < 9)
333 ok(iframe_mode === 5, "iframe_mode = " + iframe_mode);
334 else
335 ok(iframe_mode === document.documentMode, "iframe_mode = " + iframe_mode);
336 next_test();
339 iframe.src = "about:blank";
340 document.body.appendChild(iframe);
343 sync_test("conditional_comments", function() {
344 var div = document.createElement("div");
345 document.body.appendChild(div);
347 function test_version(v) {
348 var version = compat_version ? compat_version : 7;
350 div.innerHTML = "<!--[if lte IE " + v + "]>true<![endif]-->";
351 ok(div.innerText === (version <= v ? "true" : ""),
352 "div.innerText = " + div.innerText + " for version (<=) " + v);
354 div.innerHTML = "<!--[if lt IE " + v + "]>true<![endif]-->";
355 ok(div.innerText === (version < v ? "true" : ""),
356 "div.innerText = " + div.innerText + " for version (<) " + v);
358 div.innerHTML = "<!--[if gte IE " + v + "]>true<![endif]-->";
359 ok(div.innerText === (version >= v && version < 10 ? "true" : ""),
360 "div.innerText = " + div.innerText + " for version (>=) " + v);
362 div.innerHTML = "<!--[if gt IE " + v + "]>true<![endif]-->";
363 ok(div.innerText === (version > v && version < 10 ? "true" : ""),
364 "div.innerText = " + div.innerText + " for version (>) " + v);
367 test_version(5);
368 test_version(6);
369 test_version(7);
370 test_version(8);
373 var ready_states;
375 async_test("script_load", function() {
376 var v = document.documentMode;
377 if(v < 9) {
378 next_test();
379 return;
382 var elem = document.createElement("script");
383 ready_states = "";
385 elem.onreadystatechange = guard(function() {
386 ok(v < 11, "unexpected onreadystatechange call");
387 ready_states += elem.readyState + ",";
390 elem.onload = guard(function() {
391 switch(v) {
392 case 9:
393 ok(ready_states === "loading,exec,loaded,", "ready_states = " + ready_states);
394 break;
395 case 10:
396 ok(ready_states === "loading,exec,", "ready_states = " + ready_states);
397 break;
398 case 11:
399 ok(ready_states === "exec,", "ready_states = " + ready_states);
400 break;
402 next_test();
405 document.body.appendChild(elem);
406 elem.src = "jsstream.php?simple";
407 external.writeStream("simple", "ready_states += 'exec,';");
410 sync_test("navigator", function() {
411 var v = document.documentMode, re;
412 var app = navigator.appVersion;
413 ok(navigator.userAgent === "Mozilla/" + app,
414 "userAgent = " + navigator.userAgent + " appVersion = " + app);
416 re = v < 11
417 ? "^" + (v < 9 ? "4" : "5") + "\\.0 \\(compatible; MSIE " + (v < 7 ? 7 : v) +
418 "\\.0; Windows NT [0-9].[0-9]; .*Trident/[678]\\.0.*\\)$"
419 : "^5.0 \\(Windows NT [0-9].[0-9]; .*Trident/[678]\\.0.*rv:11.0\\) like Gecko$";
420 ok(new RegExp(re).test(app), "appVersion = " + app);
422 ok(navigator.appCodeName === "Mozilla", "appCodeName = " + navigator.appCodeName);
423 ok(navigator.appName === (v < 11 ? "Microsoft Internet Explorer" : "Netscape"),
424 "appName = " + navigator.appName);
425 ok(navigator.toString() === (v < 9 ? "[object]" : "[object Navigator]"),
426 "navigator.toString() = " + navigator.toString());
429 sync_test("delete_prop", function() {
430 var v = document.documentMode;
431 var obj = document.createElement("div"), r, obj2;
433 obj.prop1 = true;
434 r = false;
435 try {
436 delete obj.prop1;
437 }catch(ex) {
438 r = true;
440 if(v < 8) {
441 ok(r, "did not get an expected exception");
442 return;
444 ok(!r, "got an unexpected exception");
445 ok(!("prop1" in obj), "prop1 is still in obj");
447 /* again, this time prop1 does not exist */
448 r = false;
449 try {
450 delete obj.prop1;
451 }catch(ex) {
452 r = true;
454 if(v < 9) {
455 ok(r, "did not get an expected exception");
456 return;
457 }else {
458 ok(!r, "got an unexpected exception");
459 ok(!("prop1" in obj), "prop1 is still in obj");
462 r = (delete obj.className);
463 ok(r, "delete returned " + r);
464 ok("className" in obj, "className deleted from obj");
465 ok(obj.className === "", "className = " + obj.className);
467 /* builtin propertiles don't throw any exception, but are not really deleted */
468 r = (delete obj.tagName);
469 ok(r, "delete returned " + r);
470 ok("tagName" in obj, "tagName deleted from obj");
471 ok(obj.tagName === "DIV", "tagName = " + obj.tagName);
473 obj = document.querySelectorAll("*");
474 ok("0" in obj, "0 is not in obj");
475 obj2 = obj[0];
476 r = (delete obj[0]);
477 ok("0" in obj, "0 is not in obj");
478 ok(obj[0] === obj2, "obj[0] != obj2");
480 /* test window object and its global scope handling */
481 obj = window;
483 obj.globalprop1 = true;
484 ok(globalprop1, "globalprop1 = " + globalprop1);
485 r = false;
486 try {
487 delete obj.globalprop1;
488 }catch(ex) {
489 r = true;
491 if(v < 9) {
492 ok(r, "did not get an expected exception");
493 }else {
494 ok(!r, "got an unexpected globalprop1 exception");
495 ok(!("globalprop1" in obj), "globalprop1 is still in obj");
498 globalprop2 = true;
499 ok(obj.globalprop2, "globalprop2 = " + globalprop2);
500 r = false;
501 try {
502 delete obj.globalprop2;
503 }catch(ex) {
504 r = true;
506 if(v < 9) {
507 ok(r, "did not get an expected globalprop2 exception");
508 }else {
509 ok(!r, "got an unexpected exception");
510 todo_wine.
511 ok(!("globalprop2" in obj), "globalprop2 is still in obj");
514 obj.globalprop3 = true;
515 ok(globalprop3, "globalprop3 = " + globalprop3);
516 r = false;
517 try {
518 delete globalprop3;
519 }catch(ex) {
520 r = true;
522 if(v < 9) {
523 ok(r, "did not get an expected exception");
524 ok("globalprop3" in obj, "globalprop3 is not in obj");
525 }else {
526 ok(!r, "got an unexpected globalprop3 exception");
527 ok(!("globalprop3" in obj), "globalprop3 is still in obj");
530 globalprop4 = true;
531 ok(obj.globalprop4, "globalprop4 = " + globalprop4);
532 r = (delete globalprop4);
533 ok(r, "delete returned " + r);
534 todo_wine.
535 ok(!("globalprop4" in obj), "globalprop4 is still in obj");