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
21 function test_elem_props() {
22 var elem = document.documentElement;
24 function test_exposed(prop, expect) {
26 ok(prop in elem, prop + " not found in element.");
28 ok(!(prop in elem), prop + " found in element.");
31 var v = document.documentMode;
33 test_exposed("doScroll", v < 11);
34 test_exposed("querySelectorAll", v >= 8);
35 test_exposed("textContent", v >= 9);
36 test_exposed("prefix", v >= 9);
37 test_exposed("firstElementChild", v >= 9);
38 test_exposed("onsubmit", v >= 9);
39 test_exposed("getElementsByClassName", v >= 9);
40 test_exposed("removeAttributeNS", v >= 9);
41 test_exposed("addEventListener", v >= 9);
42 test_exposed("removeEventListener", v >= 9);
43 test_exposed("dispatchEvent", v >= 9);
48 function test_doc_props() {
49 function test_exposed(prop, expect) {
51 ok(prop in document, prop + " not found in document.");
53 ok(!(prop in document), prop + " found in document.");
56 var v = document.documentMode;
58 test_exposed("textContent", v >= 9);
59 test_exposed("prefix", v >= 9);
60 test_exposed("defaultView", v >= 9);
61 test_exposed("head", v >= 9);
62 test_exposed("addEventListener", v >= 9);
63 test_exposed("removeEventListener", v >= 9);
64 test_exposed("dispatchEvent", v >= 9);
65 test_exposed("createEvent", v >= 9);
67 test_exposed("parentWindow", true);
68 if(v >= 9) ok(document.defaultView === document.parentWindow, "defaultView != parentWindow");
73 function test_window_props() {
74 function test_exposed(prop, expect) {
76 ok(prop in window, prop + " not found in window.");
78 ok(!(prop in window), prop + " found in window.");
81 var v = document.documentMode;
83 test_exposed("postMessage", true);
84 test_exposed("addEventListener", v >= 9);
85 test_exposed("removeEventListener", v >= 9);
86 test_exposed("dispatchEvent", v >= 9);
91 function test_xhr_props() {
92 var xhr = new XMLHttpRequest();
94 function test_exposed(prop, expect) {
96 ok(prop in xhr, prop + " not found in XMLHttpRequest.");
98 ok(!(prop in xhr), prop + " found in XMLHttpRequest.");
101 var v = document.documentMode;
103 test_exposed("addEventListener", v >= 9);
104 test_exposed("removeEventListener", v >= 9);
105 test_exposed("dispatchEvent", v >= 9);
110 function test_javascript() {
113 function test_exposed(func, obj, expect) {
115 ok(func in obj, func + " not found in " + obj);
117 ok(!(func in obj), func + " found in " + obj);
120 function test_parses(code, expect) {
129 ok(success === true, code + " did not parse");
131 ok(success === false, code + " parsed");
134 var v = document.documentMode;
136 test_exposed("ScriptEngineMajorVersion", g, true);
138 test_exposed("JSON", g, v >= 8);
139 test_exposed("now", Date, true);
140 test_exposed("toISOString", Date.prototype, v >= 9);
141 test_exposed("isArray", Array, v >= 9);
142 test_exposed("indexOf", Array.prototype, v >= 9);
144 test_parses("if(false) { o.default; }", v >= 9);
145 test_parses("if(false) { o.with; }", v >= 9);
146 test_parses("if(false) { o.if; }", v >= 9);
151 function test_elem_by_id() {
152 document.body.innerHTML = '<form id="testid" name="testname"></form>';
154 var id_elem = document.getElementById("testid");
155 ok(id_elem.tagName === "FORM", "id_elem.tagName = " + id_elem.tagName);
157 var name_elem = document.getElementById("testname");
158 if(document.documentMode < 8)
159 ok(id_elem === name_elem, "id_elem != id_elem");
161 ok(name_elem === null, "name_elem != null");
166 function test_doc_mode() {
167 compat_version = parseInt(document.location.search.substring(1));
169 trace("Testing compatibility mode " + compat_version);
171 if(compat_version > 6 && compat_version > document.documentMode) {
172 win_skip("Document mode not supported (expected " + compat_version + " got " + document.documentMode + ")");
177 ok(Math.max(compat_version, 5) === document.documentMode, "documentMode = " + document.documentMode);
179 if(document.documentMode > 5)
180 ok(document.compatMode === "CSS1Compat", "document.compatMode = " + document.compatMode);
182 ok(document.compatMode === "BackCompat", "document.compatMode = " + document.compatMode);
187 function test_iframe_doc_mode() {
188 var iframe = document.createElement("iframe");
190 iframe.onload = function() {
191 var iframe_mode = iframe.contentWindow.document.documentMode;
192 if(document.documentMode < 9)
193 ok(iframe_mode === 5, "iframe_mode = " + iframe_mode);
195 ok(iframe_mode === document.documentMode, "iframe_mode = " + iframe_mode);
199 iframe.src = "about:blank";
200 document.body.appendChild(iframe);
203 function test_conditional_comments() {
204 var div = document.createElement("div");
205 document.body.appendChild(div);
207 function test_version(v) {
208 var version = compat_version ? compat_version : 7;
210 div.innerHTML = "<!--[if lte IE " + v + "]>true<![endif]-->";
211 ok(div.innerText === (version <= v ? "true" : ""),
212 "div.innerText = " + div.innerText + " for version (<=) " + v);
214 div.innerHTML = "<!--[if lt IE " + v + "]>true<![endif]-->";
215 ok(div.innerText === (version < v ? "true" : ""),
216 "div.innerText = " + div.innerText + " for version (<) " + v);
218 div.innerHTML = "<!--[if gte IE " + v + "]>true<![endif]-->";
219 ok(div.innerText === (version >= v && version < 10 ? "true" : ""),
220 "div.innerText = " + div.innerText + " for version (>=) " + v);
222 div.innerHTML = "<!--[if gt IE " + v + "]>true<![endif]-->";
223 ok(div.innerText === (version > v && version < 10 ? "true" : ""),
224 "div.innerText = " + div.innerText + " for version (>) " + v);
237 test_iframe_doc_mode,
244 test_conditional_comments