diff --git a/.eslintignore b/.eslintignore index 33f466ff0a1c..5a34442aee1f 100644 --- a/.eslintignore +++ b/.eslintignore @@ -152,7 +152,6 @@ devtools/server/tests/unit/xpcshell_debugging_script.js # Third-party dom/canvas/test/webgl-conf/ -dom/imptests/ dom/media/webaudio/test/blink/ dom/media/webvtt/ dom/svg/test/test_nonAnimStrings.xhtml diff --git a/.flake8 b/.flake8 index 2f8b012ac247..4a07ebfde1ef 100644 --- a/.flake8 +++ b/.flake8 @@ -9,7 +9,6 @@ exclude = dom/browser-element, dom/canvas, dom/encoding, - dom/imptests, dom/security, dom/websocket, gfx/tests, diff --git a/browser/components/resistfingerprinting/test/chrome/chrome.ini b/browser/components/resistfingerprinting/test/chrome/chrome.ini index 3b38765c3453..e177136ad604 100644 --- a/browser/components/resistfingerprinting/test/chrome/chrome.ini +++ b/browser/components/resistfingerprinting/test/chrome/chrome.ini @@ -1,6 +1 @@ -[DEFAULT] -support-files = - ../../../../../dom/imptests/testharness.js - ../../../../../dom/imptests/testharnessreport.js - -[test_bug1409973_date_time_format.html] \ No newline at end of file +[test_bug1409973_date_time_format.html] diff --git a/dom/imptests/README b/dom/imptests/README deleted file mode 100644 index 13906cef97bb..000000000000 --- a/dom/imptests/README +++ /dev/null @@ -1,106 +0,0 @@ -This directory contains tests imported from W3C test suites. In order to make it -as easy as possible to update these tests, no changes are made to the imported -files (names for scripted tests do get a test_ prefix to integrate with the test -runner, however). The scripts to update tests are provided. - - -======================= -Files in this directory -======================= - -Source; Usage and purpose; License - -* testharness.js / testharness.css - Directly imported from the W3C repository (), - with the updateTestharness.py script. - Provide the test harness. - W3C Test Suite License / W3C 3-clause BSD License - -* idlharness.js - Directly imported from the W3C repository (), - with the updateTestharness.py script. - Used to test WebIDL. - W3C Test Suite License / W3C 3-clause BSD License - -* WebIDLParser.js - Directly imported from the W3C repository (), - with the updateTestharness.py script. - Used by idlharness.js to parse IDL blocks. - MIT License - -* updateTestharness.py - Used to update the above files. - MPL - -* parseManifest.py - Imported from . Parses MANIFEST - files (provided in the W3C repository) as documented at - . - MIT License - -* testharnessreport.js - Glue between testharness.js and our Mochitest runner. - MPL - -* importTestsuite.py - Imports a test suite from a remote repository. Takes one argument, a file in - the format described under webapps.txt. - Note: removes both source and destination directory before starting. Do not - use with outstanding changes in either directory. - MPL - -* parseFailures.py - Parses failures out of a mochitest log and writes out JSON files and Makefiles - into the correct failures/ folder. - The mochitest log should be produced by setting the 'dumpFailures' flag in - testharnessreport.js; this will print out the encountered failures, marked - by @ signs. - MPL - -* writeBuildFiles.py - Helper functions to write out automatically generated build files. - MPL - -* Makefile.in - Integration with our build system. Installs support files into /resources and - includes a .mk file for each repository. - MPL - -* failures/ - Expected failures for tests in each repository. Each test's failures, if - any, are in a file with the same path and name with .json appended. New - expected fail files currently needed to be added manually to makefiles. - -* html.mk / webapps.mk / ... - Generated by importTestsuite.py from webapps.txt. - Contains a list of the directories with tests. To be included in Makefile.in. - -* html.txt / webapps.txt / ... - Input to importTestsuite.py. - Lists the URL of the repository and the destination directory (separated by a - vertical bar), followed by a list of directories within the repository - (separated by line feeds). - -* html / webapps / ... - Actual tests. - W3C Test Suite License / W3C 3-clause BSD License - - -===================================================================== -Importing an additional directory from an already-imported repository -===================================================================== - -Add a line to the relevant data file (e.g. webapps.txt), with the path to the -additional directory relative to the root of the remote repository, and then run -the importTestsuite.py script, passing the data file as its argument. - - -========================== -Importing a new test suite -========================== - -Create a data file in the format documented above, and run the -importTestsuite.py script, passing the data file as its argument. -This will create a foo.mk file; include this file in dom/imptests/Makefile.in. - -Add any necessary files in failures/. diff --git a/dom/imptests/WebIDLParser.js b/dom/imptests/WebIDLParser.js deleted file mode 100644 index 103a7f48bd87..000000000000 --- a/dom/imptests/WebIDLParser.js +++ /dev/null @@ -1,924 +0,0 @@ - - -(function () { - var tokenise = function (str) { - var tokens = [] - , re = { - "float": /^-?(([0-9]+\.[0-9]*|[0-9]*\.[0-9]+)([Ee][-+]?[0-9]+)?|[0-9]+[Ee][-+]?[0-9]+)/ - , "integer": /^-?(0([Xx][0-9A-Fa-f]+|[0-7]*)|[1-9][0-9]*)/ - , "identifier": /^[A-Z_a-z][0-9A-Z_a-z]*/ - , "string": /^"[^"]*"/ - , "whitespace": /^(?:[\t\n\r ]+|[\t\n\r ]*((\/\/.*|\/\*(.|\n|\r)*?\*\/)[\t\n\r ]*))+/ - , "other": /^[^\t\n\r 0-9A-Z_a-z]/ - } - , types = [] - ; - for (var k in re) types.push(k); - while (str.length > 0) { - var matched = false; - for (var i = 0, n = types.length; i < n; i++) { - var type = types[i]; - str = str.replace(re[type], function (tok) { - tokens.push({ type: type, value: tok }); - matched = true; - return ""; - }); - if (matched) break; - } - if (matched) continue; - throw new Error("Token stream not progressing"); - } - return tokens; - }; - - var parse = function (tokens, opt) { - var line = 1; - tokens = tokens.slice(); - - var FLOAT = "float" - , INT = "integer" - , ID = "identifier" - , STR = "string" - , OTHER = "other" - ; - - var WebIDLParseError = function (str, line, input, tokens) { - this.message = str; - this.line = line; - this.input = input; - this.tokens = tokens; - }; - WebIDLParseError.prototype.toString = function () { - return this.message + ", line " + this.line + " (tokens: '" + this.input + "')\n" + - JSON.stringify(this.tokens, null, 4); - }; - - var error = function (str) { - var tok = "", numTokens = 0, maxTokens = 5; - while (numTokens < maxTokens && tokens.length > numTokens) { - tok += tokens[numTokens].value; - numTokens++; - } - throw new WebIDLParseError(str, line, tok, tokens.slice(0, 5)); - }; - - var last_token = null; - - var consume = function (type, value) { - if (!tokens.length || tokens[0].type !== type) return; - if (typeof value === "undefined" || tokens[0].value === value) { - last_token = tokens.shift(); - if (type === ID) last_token.value = last_token.value.replace(/^_/, ""); - return last_token; - } - }; - - var ws = function () { - if (!tokens.length) return; - if (tokens[0].type === "whitespace") { - var t = tokens.shift(); - t.value.replace(/\n/g, function (m) { line++; return m; }); - return t; - } - }; - - var all_ws = function (store, pea) { // pea == post extended attribute, tpea = same for types - var t = { type: "whitespace", value: "" }; - while (true) { - var w = ws(); - if (!w) break; - t.value += w.value; - } - if (t.value.length > 0) { - if (store) { - var w = t.value - , re = { - "ws": /^([\t\n\r ]+)/ - , "line-comment": /^\/\/(.*)\n?/m - , "multiline-comment": /^\/\*((?:.|\n|\r)*?)\*\// - } - , wsTypes = [] - ; - for (var k in re) wsTypes.push(k); - while (w.length) { - var matched = false; - for (var i = 0, n = wsTypes.length; i < n; i++) { - var type = wsTypes[i]; - w = w.replace(re[type], function (tok, m1) { - store.push({ type: type + (pea ? ("-" + pea) : ""), value: m1 }); - matched = true; - return ""; - }); - if (matched) break; - } - if (matched) continue; - throw new Error("Surprising white space construct."); // this shouldn't happen - } - } - return t; - } - }; - - var integer_type = function () { - var ret = ""; - all_ws(); - if (consume(ID, "unsigned")) ret = "unsigned "; - all_ws(); - if (consume(ID, "short")) return ret + "short"; - if (consume(ID, "long")) { - ret += "long"; - all_ws(); - if (consume(ID, "long")) return ret + " long"; - return ret; - } - if (ret) error("Failed to parse integer type"); - }; - - var float_type = function () { - var ret = ""; - all_ws(); - if (consume(ID, "unrestricted")) ret = "unrestricted "; - all_ws(); - if (consume(ID, "float")) return ret + "float"; - if (consume(ID, "double")) return ret + "double"; - if (ret) error("Failed to parse float type"); - }; - - var primitive_type = function () { - var num_type = integer_type() || float_type(); - if (num_type) return num_type; - all_ws(); - if (consume(ID, "boolean")) return "boolean"; - if (consume(ID, "byte")) return "byte"; - if (consume(ID, "octet")) return "octet"; - }; - - var const_value = function () { - if (consume(ID, "true")) return { type: "boolean", value: true }; - if (consume(ID, "false")) return { type: "boolean", value: false }; - if (consume(ID, "null")) return { type: "null" }; - if (consume(ID, "Infinity")) return { type: "Infinity", negative: false }; - if (consume(ID, "NaN")) return { type: "NaN" }; - var ret = consume(FLOAT) || consume(INT); - if (ret) return { type: "number", value: 1 * ret.value }; - var tok = consume(OTHER, "-"); - if (tok) { - if (consume(ID, "Infinity")) return { type: "Infinity", negative: true }; - else tokens.unshift(tok); - } - }; - - var type_suffix = function (obj) { - while (true) { - all_ws(); - if (consume(OTHER, "?")) { - if (obj.nullable) error("Can't nullable more than once"); - obj.nullable = true; - } - else if (consume(OTHER, "[")) { - all_ws(); - consume(OTHER, "]") || error("Unterminated array type"); - if (!obj.array) { - obj.array = 1; - obj.nullableArray = [obj.nullable]; - } - else { - obj.array++; - obj.nullableArray.push(obj.nullable); - } - obj.nullable = false; - } - else return; - } - }; - - var single_type = function () { - var prim = primitive_type() - , ret = { sequence: false, generic: null, nullable: false, array: false, union: false } - , name - , value - ; - if (prim) { - ret.idlType = prim; - } - else if (name = consume(ID)) { - value = name.value; - all_ws(); - // Generic types - if (consume(OTHER, "<")) { - // backwards compat - if (value === "sequence") { - ret.sequence = true; - } - ret.generic = value; - ret.idlType = type() || error("Error parsing generic type " + value); - all_ws(); - if (!consume(OTHER, ">")) error("Unterminated generic type " + value); - all_ws(); - if (consume(OTHER, "?")) ret.nullable = true; - return ret; - } - else { - ret.idlType = value; - } - } - else { - return; - } - type_suffix(ret); - if (ret.nullable && !ret.array && ret.idlType === "any") error("Type any cannot be made nullable"); - return ret; - }; - - var union_type = function () { - all_ws(); - if (!consume(OTHER, "(")) return; - var ret = { sequence: false, generic: null, nullable: false, array: false, union: true, idlType: [] }; - var fst = type() || error("Union type with no content"); - ret.idlType.push(fst); - while (true) { - all_ws(); - if (!consume(ID, "or")) break; - var typ = type() || error("No type after 'or' in union type"); - ret.idlType.push(typ); - } - if (!consume(OTHER, ")")) error("Unterminated union type"); - type_suffix(ret); - return ret; - }; - - var type = function () { - return single_type() || union_type(); - }; - - var argument = function (store) { - var ret = { optional: false, variadic: false }; - ret.extAttrs = extended_attrs(store); - all_ws(store, "pea"); - var opt_token = consume(ID, "optional"); - if (opt_token) { - ret.optional = true; - all_ws(); - } - ret.idlType = type(); - if (!ret.idlType) { - if (opt_token) tokens.unshift(opt_token); - return; - } - var type_token = last_token; - if (!ret.optional) { - all_ws(); - if (tokens.length >= 3 && - tokens[0].type === "other" && tokens[0].value === "." && - tokens[1].type === "other" && tokens[1].value === "." && - tokens[2].type === "other" && tokens[2].value === "." - ) { - tokens.shift(); - tokens.shift(); - tokens.shift(); - ret.variadic = true; - } - } - all_ws(); - var name = consume(ID); - if (!name) { - if (opt_token) tokens.unshift(opt_token); - tokens.unshift(type_token); - return; - } - ret.name = name.value; - if (ret.optional) { - all_ws(); - ret["default"] = default_(); - } - return ret; - }; - - var argument_list = function (store) { - var ret = [] - , arg = argument(store ? ret : null) - ; - if (!arg) return; - ret.push(arg); - while (true) { - all_ws(store ? ret : null); - if (!consume(OTHER, ",")) return ret; - var nxt = argument(store ? ret : null) || error("Trailing comma in arguments list"); - ret.push(nxt); - } - }; - - var type_pair = function () { - all_ws(); - var k = type(); - if (!k) return; - all_ws() - if (!consume(OTHER, ",")) return; - all_ws(); - var v = type(); - if (!v) return; - return [k, v]; - }; - - var simple_extended_attr = function (store) { - all_ws(); - var name = consume(ID); - if (!name) return; - var ret = { - name: name.value - , "arguments": null - }; - all_ws(); - var eq = consume(OTHER, "="); - if (eq) { - all_ws(); - ret.rhs = consume(ID); - if (!ret.rhs) return error("No right hand side to extended attribute assignment"); - } - all_ws(); - if (consume(OTHER, "(")) { - var args, pair; - // [Constructor(DOMString str)] - if (args = argument_list(store)) { - ret["arguments"] = args; - } - // [MapClass(DOMString, DOMString)] - else if (pair = type_pair()) { - ret.typePair = pair; - } - // [Constructor()] - else { - ret["arguments"] = []; - } - all_ws(); - consume(OTHER, ")") || error("Unexpected token in extended attribute argument list or type pair"); - } - return ret; - }; - - // Note: we parse something simpler than the official syntax. It's all that ever - // seems to be used - var extended_attrs = function (store) { - var eas = []; - all_ws(store); - if (!consume(OTHER, "[")) return eas; - eas[0] = simple_extended_attr(store) || error("Extended attribute with not content"); - all_ws(); - while (consume(OTHER, ",")) { - eas.push(simple_extended_attr(store) || error("Trailing comma in extended attribute")); - all_ws(); - } - consume(OTHER, "]") || error("No end of extended attribute"); - return eas; - }; - - var default_ = function () { - all_ws(); - if (consume(OTHER, "=")) { - all_ws(); - var def = const_value(); - if (def) { - return def; - } - else { - var str = consume(STR) || error("No value for default"); - str.value = str.value.replace(/^"/, "").replace(/"$/, ""); - return str; - } - } - }; - - var const_ = function (store) { - all_ws(store, "pea"); - if (!consume(ID, "const")) return; - var ret = { type: "const", nullable: false }; - all_ws(); - var typ = primitive_type(); - if (!typ) { - typ = consume(ID) || error("No type for const"); - typ = typ.value; - } - ret.idlType = typ; - all_ws(); - if (consume(OTHER, "?")) { - ret.nullable = true; - all_ws(); - } - var name = consume(ID) || error("No name for const"); - ret.name = name.value; - all_ws(); - consume(OTHER, "=") || error("No value assignment for const"); - all_ws(); - var cnt = const_value(); - if (cnt) ret.value = cnt; - else error("No value for const"); - all_ws(); - consume(OTHER, ";") || error("Unterminated const"); - return ret; - }; - - var inheritance = function () { - all_ws(); - if (consume(OTHER, ":")) { - all_ws(); - var inh = consume(ID) || error ("No type in inheritance"); - return inh.value; - } - }; - - var operation_rest = function (ret, store) { - all_ws(); - if (!ret) ret = {}; - var name = consume(ID); - ret.name = name ? name.value : null; - all_ws(); - consume(OTHER, "(") || error("Invalid operation"); - ret["arguments"] = argument_list(store) || []; - all_ws(); - consume(OTHER, ")") || error("Unterminated operation"); - all_ws(); - consume(OTHER, ";") || error("Unterminated operation"); - return ret; - }; - - var callback = function (store) { - all_ws(store, "pea"); - var ret; - if (!consume(ID, "callback")) return; - all_ws(); - var tok = consume(ID, "interface"); - if (tok) { - tokens.unshift(tok); - ret = interface_(); - ret.type = "callback interface"; - return ret; - } - var name = consume(ID) || error("No name for callback"); - ret = { type: "callback", name: name.value }; - all_ws(); - consume(OTHER, "=") || error("No assignment in callback"); - all_ws(); - ret.idlType = return_type(); - all_ws(); - consume(OTHER, "(") || error("No arguments in callback"); - ret["arguments"] = argument_list(store) || []; - all_ws(); - consume(OTHER, ")") || error("Unterminated callback"); - all_ws(); - consume(OTHER, ";") || error("Unterminated callback"); - return ret; - }; - - var attribute = function (store) { - all_ws(store, "pea"); - var grabbed = [] - , ret = { - type: "attribute" - , "static": false - , stringifier: false - , inherit: false - , readonly: false - }; - if (consume(ID, "static")) { - ret["static"] = true; - grabbed.push(last_token); - } - else if (consume(ID, "stringifier")) { - ret.stringifier = true; - grabbed.push(last_token); - } - var w = all_ws(); - if (w) grabbed.push(w); - if (consume(ID, "inherit")) { - if (ret["static"] || ret.stringifier) error("Cannot have a static or stringifier inherit"); - ret.inherit = true; - grabbed.push(last_token); - var w = all_ws(); - if (w) grabbed.push(w); - } - if (consume(ID, "readonly")) { - ret.readonly = true; - grabbed.push(last_token); - var w = all_ws(); - if (w) grabbed.push(w); - } - if (!consume(ID, "attribute")) { - tokens = grabbed.concat(tokens); - return; - } - all_ws(); - ret.idlType = type() || error("No type in attribute"); - if (ret.idlType.sequence) error("Attributes cannot accept sequence types"); - all_ws(); - var name = consume(ID) || error("No name in attribute"); - ret.name = name.value; - all_ws(); - consume(OTHER, ";") || error("Unterminated attribute"); - return ret; - }; - - var return_type = function () { - var typ = type(); - if (!typ) { - if (consume(ID, "void")) { - return "void"; - } - else error("No return type"); - } - return typ; - }; - - var operation = function (store) { - all_ws(store, "pea"); - var ret = { - type: "operation" - , getter: false - , setter: false - , creator: false - , deleter: false - , legacycaller: false - , "static": false - , stringifier: false - }; - while (true) { - all_ws(); - if (consume(ID, "getter")) ret.getter = true; - else if (consume(ID, "setter")) ret.setter = true; - else if (consume(ID, "creator")) ret.creator = true; - else if (consume(ID, "deleter")) ret.deleter = true; - else if (consume(ID, "legacycaller")) ret.legacycaller = true; - else break; - } - if (ret.getter || ret.setter || ret.creator || ret.deleter || ret.legacycaller) { - all_ws(); - ret.idlType = return_type(); - operation_rest(ret, store); - return ret; - } - if (consume(ID, "static")) { - ret["static"] = true; - ret.idlType = return_type(); - operation_rest(ret, store); - return ret; - } - else if (consume(ID, "stringifier")) { - ret.stringifier = true; - all_ws(); - if (consume(OTHER, ";")) return ret; - ret.idlType = return_type(); - operation_rest(ret, store); - return ret; - } - ret.idlType = return_type(); - all_ws(); - if (consume(ID, "iterator")) { - all_ws(); - ret.type = "iterator"; - if (consume(ID, "object")) { - ret.iteratorObject = "object"; - } - else if (consume(OTHER, "=")) { - all_ws(); - var name = consume(ID) || error("No right hand side in iterator"); - ret.iteratorObject = name.value; - } - all_ws(); - consume(OTHER, ";") || error("Unterminated iterator"); - return ret; - } - else { - operation_rest(ret, store); - return ret; - } - }; - - var identifiers = function (arr) { - while (true) { - all_ws(); - if (consume(OTHER, ",")) { - all_ws(); - var name = consume(ID) || error("Trailing comma in identifiers list"); - arr.push(name.value); - } - else break; - } - }; - - var serialiser = function (store) { - all_ws(store, "pea"); - if (!consume(ID, "serializer")) return; - var ret = { type: "serializer" }; - all_ws(); - if (consume(OTHER, "=")) { - all_ws(); - if (consume(OTHER, "{")) { - ret.patternMap = true; - all_ws(); - var id = consume(ID); - if (id && id.value === "getter") { - ret.names = ["getter"]; - } - else if (id && id.value === "inherit") { - ret.names = ["inherit"]; - identifiers(ret.names); - } - else if (id) { - ret.names = [id.value]; - identifiers(ret.names); - } - else { - ret.names = []; - } - all_ws(); - consume(OTHER, "}") || error("Unterminated serializer pattern map"); - } - else if (consume(OTHER, "[")) { - ret.patternList = true; - all_ws(); - var id = consume(ID); - if (id && id.value === "getter") { - ret.names = ["getter"]; - } - else if (id) { - ret.names = [id.value]; - identifiers(ret.names); - } - else { - ret.names = []; - } - all_ws(); - consume(OTHER, "]") || error("Unterminated serializer pattern list"); - } - else { - var name = consume(ID) || error("Invalid serializer"); - ret.name = name.value; - } - all_ws(); - consume(OTHER, ";") || error("Unterminated serializer"); - return ret; - } - else if (consume(OTHER, ";")) { - // noop, just parsing - } - else { - ret.idlType = return_type(); - all_ws(); - ret.operation = operation_rest(null, store); - } - return ret; - }; - - var interface_ = function (isPartial, store) { - all_ws(isPartial ? null : store, "pea"); - if (!consume(ID, "interface")) return; - all_ws(); - var name = consume(ID) || error("No name for interface"); - var mems = [] - , ret = { - type: "interface" - , name: name.value - , partial: false - , members: mems - }; - if (!isPartial) ret.inheritance = inheritance() || null; - all_ws(); - consume(OTHER, "{") || error("Bodyless interface"); - while (true) { - all_ws(store ? mems : null); - if (consume(OTHER, "}")) { - all_ws(); - consume(OTHER, ";") || error("Missing semicolon after interface"); - return ret; - } - var ea = extended_attrs(store ? mems : null); - all_ws(); - var cnt = const_(store ? mems : null); - if (cnt) { - cnt.extAttrs = ea; - ret.members.push(cnt); - continue; - } - var mem = serialiser(store ? mems : null) || - attribute(store ? mems : null) || - operation(store ? mems : null) || - error("Unknown member"); - mem.extAttrs = ea; - ret.members.push(mem); - } - }; - - var partial = function (store) { - all_ws(store, "pea"); - if (!consume(ID, "partial")) return; - var thing = dictionary(true, store) || - interface_(true, store) || - error("Partial doesn't apply to anything"); - thing.partial = true; - return thing; - }; - - var dictionary = function (isPartial, store) { - all_ws(isPartial ? null : store, "pea"); - if (!consume(ID, "dictionary")) return; - all_ws(); - var name = consume(ID) || error("No name for dictionary"); - var mems = [] - , ret = { - type: "dictionary" - , name: name.value - , partial: false - , members: mems - }; - if (!isPartial) ret.inheritance = inheritance() || null; - all_ws(); - consume(OTHER, "{") || error("Bodyless dictionary"); - while (true) { - all_ws(store ? mems : null); - if (consume(OTHER, "}")) { - all_ws(); - consume(OTHER, ";") || error("Missing semicolon after dictionary"); - return ret; - } - var ea = extended_attrs(store ? mems : null); - all_ws(store ? mems : null, "pea"); - var typ = type() || error("No type for dictionary member"); - all_ws(); - var name = consume(ID) || error("No name for dictionary member"); - ret.members.push({ - type: "field" - , name: name.value - , idlType: typ - , extAttrs: ea - , "default": default_() - }); - all_ws(); - consume(OTHER, ";") || error("Unterminated dictionary member"); - } - }; - - var exception = function (store) { - all_ws(store, "pea"); - if (!consume(ID, "exception")) return; - all_ws(); - var name = consume(ID) || error("No name for exception"); - var mems = [] - , ret = { - type: "exception" - , name: name.value - , members: mems - }; - ret.inheritance = inheritance() || null; - all_ws(); - consume(OTHER, "{") || error("Bodyless exception"); - while (true) { - all_ws(store ? mems : null); - if (consume(OTHER, "}")) { - all_ws(); - consume(OTHER, ";") || error("Missing semicolon after exception"); - return ret; - } - var ea = extended_attrs(store ? mems : null); - all_ws(store ? mems : null, "pea"); - var cnt = const_(); - if (cnt) { - cnt.extAttrs = ea; - ret.members.push(cnt); - } - else { - var typ = type(); - all_ws(); - var name = consume(ID); - all_ws(); - if (!typ || !name || !consume(OTHER, ";")) error("Unknown member in exception body"); - ret.members.push({ - type: "field" - , name: name.value - , idlType: typ - , extAttrs: ea - }); - } - } - }; - - var enum_ = function (store) { - all_ws(store, "pea"); - if (!consume(ID, "enum")) return; - all_ws(); - var name = consume(ID) || error("No name for enum"); - var vals = [] - , ret = { - type: "enum" - , name: name.value - , values: vals - }; - all_ws(); - consume(OTHER, "{") || error("No curly for enum"); - var saw_comma = false; - while (true) { - all_ws(store ? vals : null); - if (consume(OTHER, "}")) { - all_ws(); - if (saw_comma) error("Trailing comma in enum"); - consume(OTHER, ";") || error("No semicolon after enum"); - return ret; - } - var val = consume(STR) || error("Unexpected value in enum"); - ret.values.push(val.value.replace(/"/g, "")); - all_ws(store ? vals : null); - if (consume(OTHER, ",")) { - if (store) vals.push({ type: "," }); - all_ws(store ? vals : null); - saw_comma = true; - } - else { - saw_comma = false; - } - } - }; - - var typedef = function (store) { - all_ws(store, "pea"); - if (!consume(ID, "typedef")) return; - var ret = { - type: "typedef" - }; - all_ws(); - ret.typeExtAttrs = extended_attrs(); - all_ws(store, "tpea"); - ret.idlType = type() || error("No type in typedef"); - all_ws(); - var name = consume(ID) || error("No name in typedef"); - ret.name = name.value; - all_ws(); - consume(OTHER, ";") || error("Unterminated typedef"); - return ret; - }; - - var implements_ = function (store) { - all_ws(store, "pea"); - var target = consume(ID); - if (!target) return; - var w = all_ws(); - if (consume(ID, "implements")) { - var ret = { - type: "implements" - , target: target.value - }; - all_ws(); - var imp = consume(ID) || error("Incomplete implements statement"); - ret["implements"] = imp.value; - all_ws(); - consume(OTHER, ";") || error("No terminating ; for implements statement"); - return ret; - } - else { - // rollback - tokens.unshift(w); - tokens.unshift(target); - } - }; - - var definition = function (store) { - return callback(store) || - interface_(false, store) || - partial(store) || - dictionary(false, store) || - exception(store) || - enum_(store) || - typedef(store) || - implements_(store) - ; - }; - - var definitions = function (store) { - if (!tokens.length) return []; - var defs = []; - while (true) { - var ea = extended_attrs(store ? defs : null) - , def = definition(store ? defs : null); - if (!def) { - if (ea.length) error("Stray extended attributes"); - break; - } - def.extAttrs = ea; - defs.push(def); - } - return defs; - }; - var res = definitions(opt.ws); - if (tokens.length) error("Unrecognised tokens"); - return res; - }; - - var inNode = typeof module !== "undefined" && module.exports - , obj = { - parse: function (str, opt) { - if (!opt) opt = {}; - var tokens = tokenise(str); - return parse(tokens, opt); - } - }; - - if (inNode) module.exports = obj; - else self.WebIDL2 = obj; -}()); diff --git a/dom/imptests/editing/mochitest.ini b/dom/imptests/editing/mochitest.ini deleted file mode 100644 index b5c82f5d494e..000000000000 --- a/dom/imptests/editing/mochitest.ini +++ /dev/null @@ -1,26 +0,0 @@ -# THIS FILE IS AUTOGENERATED BY importTestsuite.py - DO NOT EDIT -[DEFAULT] -support-files = - conformancetest/data.js - css/reset.css - implementation.js - selecttest/common.js - selecttest/test-iframe.html - tests.js - -[conformancetest/test_event.html] -[conformancetest/test_runtest.html] -skip-if = toolkit == 'android' -[selecttest/test_Document-open.html] -[selecttest/test_addRange.html] -skip-if = toolkit == 'android' #android(bug 775227) -[selecttest/test_collapse.html] -[selecttest/test_collapseToStartEnd.html] -[selecttest/test_deleteFromDocument.html] -[selecttest/test_extend.html] -[selecttest/test_getRangeAt.html] -[selecttest/test_getSelection.html] -[selecttest/test_interfaces.html] -[selecttest/test_isCollapsed.html] -[selecttest/test_removeAllRanges.html] -[selecttest/test_selectAllChildren.html] diff --git a/dom/imptests/failures/html/dom/nodes/mochitest.ini b/dom/imptests/failures/html/dom/nodes/mochitest.ini deleted file mode 100644 index 4fb17f193b8b..000000000000 --- a/dom/imptests/failures/html/dom/nodes/mochitest.ini +++ /dev/null @@ -1,13 +0,0 @@ -# THIS FILE IS AUTOGENERATED BY parseFailures.py - DO NOT EDIT -[DEFAULT] -support-files = - - -[test_Document-createElement-namespace.html.json] -[test_Document-createElementNS.html.json] -[test_Document-getElementsByTagName.html.json] -[test_Node-properties.html.json] -[test_attributes.html.json] -[test_case.html.json] -[test_getElementsByClassName-10.xml.json] -[test_getElementsByClassName-11.xml.json] diff --git a/dom/imptests/failures/html/dom/ranges/mochitest.ini b/dom/imptests/failures/html/dom/ranges/mochitest.ini deleted file mode 100644 index da0d1a7711c4..000000000000 --- a/dom/imptests/failures/html/dom/ranges/mochitest.ini +++ /dev/null @@ -1,7 +0,0 @@ -# THIS FILE IS AUTOGENERATED BY parseFailures.py - DO NOT EDIT -[DEFAULT] -support-files = - - -[test_Range-insertNode.html.json] -[test_Range-surroundContents.html.json] diff --git a/dom/imptests/failures/html/dom/ranges/test_Range-insertNode.html.json b/dom/imptests/failures/html/dom/ranges/test_Range-insertNode.html.json deleted file mode 100644 index a5ac1621d285..000000000000 --- a/dom/imptests/failures/html/dom/ranges/test_Range-insertNode.html.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "0,1: resulting range position for range [paras[0].firstChild, 0, paras[0].firstChild, 0], node paras[0].firstChild": true, - "4,2: resulting range position for range [paras[1].firstChild, 0, paras[1].firstChild, 0], node paras[1].firstChild": true, - "6,6: resulting range position for range [detachedPara1.firstChild, 0, detachedPara1.firstChild, 0], node detachedPara1.firstChild": true, - "8,4: resulting range position for range [foreignPara1.firstChild, 0, foreignPara1.firstChild, 0], node foreignPara1.firstChild": true -} diff --git a/dom/imptests/failures/html/dom/ranges/test_Range-surroundContents.html.json b/dom/imptests/failures/html/dom/ranges/test_Range-surroundContents.html.json deleted file mode 100644 index 720ee5edb632..000000000000 --- a/dom/imptests/failures/html/dom/ranges/test_Range-surroundContents.html.json +++ /dev/null @@ -1,44 +0,0 @@ -{ - "0,1: resulting range position for range [paras[0].firstChild, 0, paras[0].firstChild, 0], node paras[0].firstChild": true, - "1,1: resulting range position for range [paras[0].firstChild, 0, paras[0].firstChild, 1], node paras[0].firstChild": true, - "2,1: resulting range position for range [paras[0].firstChild, 2, paras[0].firstChild, 8], node paras[0].firstChild": true, - "3,1: resulting range position for range [paras[0].firstChild, 2, paras[0].firstChild, 9], node paras[0].firstChild": true, - "4,2: resulting range position for range [paras[1].firstChild, 0, paras[1].firstChild, 0], node paras[1].firstChild": true, - "5,2: resulting range position for range [paras[1].firstChild, 2, paras[1].firstChild, 9], node paras[1].firstChild": true, - "6,6: resulting range position for range [detachedPara1.firstChild, 0, detachedPara1.firstChild, 0], node detachedPara1.firstChild": true, - "7,6: resulting range position for range [detachedPara1.firstChild, 2, detachedPara1.firstChild, 8], node detachedPara1.firstChild": true, - "8,4: resulting range position for range [foreignPara1.firstChild, 0, foreignPara1.firstChild, 0], node foreignPara1.firstChild": true, - "9,4: resulting range position for range [foreignPara1.firstChild, 2, foreignPara1.firstChild, 8], node foreignPara1.firstChild": true, - "37,0: resulting DOM for range [processingInstruction, 0, processingInstruction, 4], node paras[0]": true, - "37,0: resulting range position for range [processingInstruction, 0, processingInstruction, 4], node paras[0]": true, - "37,1: resulting DOM for range [processingInstruction, 0, processingInstruction, 4], node paras[0].firstChild": true, - "37,1: resulting range position for range [processingInstruction, 0, processingInstruction, 4], node paras[0].firstChild": true, - "37,2: resulting DOM for range [processingInstruction, 0, processingInstruction, 4], node paras[1].firstChild": true, - "37,2: resulting range position for range [processingInstruction, 0, processingInstruction, 4], node paras[1].firstChild": true, - "37,3: resulting DOM for range [processingInstruction, 0, processingInstruction, 4], node foreignPara1": true, - "37,3: resulting range position for range [processingInstruction, 0, processingInstruction, 4], node foreignPara1": true, - "37,4: resulting DOM for range [processingInstruction, 0, processingInstruction, 4], node foreignPara1.firstChild": true, - "37,4: resulting range position for range [processingInstruction, 0, processingInstruction, 4], node foreignPara1.firstChild": true, - "37,5: resulting DOM for range [processingInstruction, 0, processingInstruction, 4], node detachedPara1": true, - "37,5: resulting range position for range [processingInstruction, 0, processingInstruction, 4], node detachedPara1": true, - "37,6: resulting DOM for range [processingInstruction, 0, processingInstruction, 4], node detachedPara1.firstChild": true, - "37,6: resulting range position for range [processingInstruction, 0, processingInstruction, 4], node detachedPara1.firstChild": true, - "37,8: resulting DOM for range [processingInstruction, 0, processingInstruction, 4], node detachedDiv": true, - "37,8: resulting range position for range [processingInstruction, 0, processingInstruction, 4], node detachedDiv": true, - "37,10: resulting DOM for range [processingInstruction, 0, processingInstruction, 4], node foreignPara2": true, - "37,10: resulting range position for range [processingInstruction, 0, processingInstruction, 4], node foreignPara2": true, - "37,12: resulting DOM for range [processingInstruction, 0, processingInstruction, 4], node xmlElement": true, - "37,12: resulting range position for range [processingInstruction, 0, processingInstruction, 4], node xmlElement": true, - "37,13: resulting DOM for range [processingInstruction, 0, processingInstruction, 4], node detachedTextNode": true, - "37,13: resulting range position for range [processingInstruction, 0, processingInstruction, 4], node detachedTextNode": true, - "37,14: resulting DOM for range [processingInstruction, 0, processingInstruction, 4], node foreignTextNode": true, - "37,14: resulting range position for range [processingInstruction, 0, processingInstruction, 4], node foreignTextNode": true, - "37,15: resulting DOM for range [processingInstruction, 0, processingInstruction, 4], node processingInstruction": true, - "37,15: resulting range position for range [processingInstruction, 0, processingInstruction, 4], node processingInstruction": true, - "37,16: resulting DOM for range [processingInstruction, 0, processingInstruction, 4], node detachedProcessingInstruction": true, - "37,16: resulting range position for range [processingInstruction, 0, processingInstruction, 4], node detachedProcessingInstruction": true, - "37,17: resulting DOM for range [processingInstruction, 0, processingInstruction, 4], node comment": true, - "37,17: resulting range position for range [processingInstruction, 0, processingInstruction, 4], node comment": true, - "37,18: resulting DOM for range [processingInstruction, 0, processingInstruction, 4], node detachedComment": true, - "37,18: resulting range position for range [processingInstruction, 0, processingInstruction, 4], node detachedComment": true -} diff --git a/dom/imptests/failures/html/dom/test_historical.html.json b/dom/imptests/failures/html/dom/test_historical.html.json deleted file mode 100644 index 42e78b23d509..000000000000 --- a/dom/imptests/failures/html/dom/test_historical.html.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "Historical DOM features must be removed: CDATASection": true, - "Historical DOM features must be removed: createCDATASection": true, - "Historical DOM features must be removed: createAttribute": true, - "Historical DOM features must be removed: createAttributeNS": true, - "Historical DOM features must be removed: getAttributeNode": true, - "Historical DOM features must be removed: getAttributeNodeNS": true, - "Historical DOM features must be removed: setAttributeNode": true, - "Historical DOM features must be removed: removeAttributeNode": true -} diff --git a/dom/imptests/failures/html/html/browsers/the-window-object/test_window-named-properties.html.json b/dom/imptests/failures/html/html/browsers/the-window-object/test_window-named-properties.html.json deleted file mode 100644 index 2c63c0851048..000000000000 --- a/dom/imptests/failures/html/html/browsers/the-window-object/test_window-named-properties.html.json +++ /dev/null @@ -1,2 +0,0 @@ -{ -} diff --git a/dom/imptests/failures/html/html/browsers/the-window-object/test_window-properties.html.json b/dom/imptests/failures/html/html/browsers/the-window-object/test_window-properties.html.json deleted file mode 100644 index b34f6573fa91..000000000000 --- a/dom/imptests/failures/html/html/browsers/the-window-object/test_window-properties.html.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "EventTarget method: addEventListener": true, - "EventTarget method: removeEventListener": true, - "EventTarget method: dispatchEvent": true, - "Window readonly attribute: history": true, - "Window readonly attribute: parent": true, - "Window readonly attribute: frameElement": true, - "Window readonly attribute: navigator": true, - "Window readonly attribute: external": true, - "Window readonly attribute: applicationCache": true, - "Window readonly attribute: sessionStorage": true, - "Window readonly attribute: localStorage": true, - "Window readonly attribute: screen": true, - "Window readonly attribute: innerWidth": true, - "Window readonly attribute: innerHeight": true, - "Window readonly attribute: scrollX": true, - "Window readonly attribute: pageXOffset": true, - "Window readonly attribute: scrollY": true, - "Window readonly attribute: pageYOffset": true, - "Window readonly attribute: screenX": true, - "Window readonly attribute: screenY": true, - "Window readonly attribute: outerWidth": true, - "Window readonly attribute: outerHeight": true, - "Window attribute: oncancel": true, - "Window attribute: onclose": true, - "Window attribute: oncuechange": true, - "Window attribute: onmousewheel": true, - "Window unforgeable attribute: window": true, - "Window unforgeable attribute: document": true, - "Window unforgeable attribute: top": true -} diff --git a/dom/imptests/failures/html/html/dom/documents/dta/mochitest.ini b/dom/imptests/failures/html/html/dom/documents/dta/mochitest.ini deleted file mode 100644 index 6777d581622c..000000000000 --- a/dom/imptests/failures/html/html/dom/documents/dta/mochitest.ini +++ /dev/null @@ -1,11 +0,0 @@ -# THIS FILE IS AUTOGENERATED BY parseFailures.py - DO NOT EDIT -[DEFAULT] -support-files = - - -[test_document.title-06.html.json] -[test_nameditem-02.html.json] -[test_nameditem-03.html.json] -[test_nameditem-04.html.json] -[test_nameditem-05.html.json] -[test_nameditem-06.html.json] diff --git a/dom/imptests/failures/html/html/dom/documents/dta/test_nameditem-06.html.json b/dom/imptests/failures/html/html/dom/documents/dta/test_nameditem-06.html.json deleted file mode 100644 index 504194194b66..000000000000 --- a/dom/imptests/failures/html/html/dom/documents/dta/test_nameditem-06.html.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "If there are two imgs, a collection should be returned. (name)": true -} diff --git a/dom/imptests/failures/html/typedarrays/mochitest.ini b/dom/imptests/failures/html/typedarrays/mochitest.ini deleted file mode 100644 index 90d5fe8020ae..000000000000 --- a/dom/imptests/failures/html/typedarrays/mochitest.ini +++ /dev/null @@ -1,6 +0,0 @@ -# THIS FILE IS AUTOGENERATED BY parseFailures.py - DO NOT EDIT -[DEFAULT] -support-files = - - -[test_constructors.html.json] diff --git a/dom/imptests/failures/html/typedarrays/test_constructors.html.json b/dom/imptests/failures/html/typedarrays/test_constructors.html.json deleted file mode 100644 index 330065dd26c9..000000000000 --- a/dom/imptests/failures/html/typedarrays/test_constructors.html.json +++ /dev/null @@ -1,48 +0,0 @@ -{ - "Constructing interface Int8Array with no arguments should throw.": true, - "Constructing interface Uint8Array with no arguments should throw.": true, - "Constructing interface Uint8ClampedArray with no arguments should throw.": true, - "Constructing interface Int16Array with no arguments should throw.": true, - "Constructing interface Uint16Array with no arguments should throw.": true, - "Constructing interface Int32Array with no arguments should throw.": true, - "Constructing interface Uint32Array with no arguments should throw.": true, - "Constructing interface Float32Array with no arguments should throw.": true, - "Constructing interface Float64Array with no arguments should throw.": true, - "Constructing interface ArrayBuffer with no arguments should throw.": true, - "The argument Infinity (1) should be interpreted as 0 for interface Int8Array.": true, - "The argument -Infinity (2) should be interpreted as 0 for interface Int8Array.": true, - "The argument -4043309056 (10) should be interpreted as 251658240 for interface Int8Array.": true, - "The argument object \"[object Object]\" (18) should be interpreted as 0 for interface Int8Array.": true, - "The argument Infinity (1) should be interpreted as 0 for interface Uint8Array.": true, - "The argument -Infinity (2) should be interpreted as 0 for interface Uint8Array.": true, - "The argument -4043309056 (10) should be interpreted as 251658240 for interface Uint8Array.": true, - "The argument object \"[object Object]\" (18) should be interpreted as 0 for interface Uint8Array.": true, - "The argument Infinity (1) should be interpreted as 0 for interface Uint8ClampedArray.": true, - "The argument -Infinity (2) should be interpreted as 0 for interface Uint8ClampedArray.": true, - "The argument -4043309056 (10) should be interpreted as 251658240 for interface Uint8ClampedArray.": true, - "The argument object \"[object Object]\" (18) should be interpreted as 0 for interface Uint8ClampedArray.": true, - "The argument Infinity (1) should be interpreted as 0 for interface Int16Array.": true, - "The argument -Infinity (2) should be interpreted as 0 for interface Int16Array.": true, - "The argument -4043309056 (10) should be interpreted as 251658240 for interface Int16Array.": true, - "The argument object \"[object Object]\" (18) should be interpreted as 0 for interface Int16Array.": true, - "The argument Infinity (1) should be interpreted as 0 for interface Uint16Array.": true, - "The argument -Infinity (2) should be interpreted as 0 for interface Uint16Array.": true, - "The argument -4043309056 (10) should be interpreted as 251658240 for interface Uint16Array.": true, - "The argument object \"[object Object]\" (18) should be interpreted as 0 for interface Uint16Array.": true, - "The argument Infinity (1) should be interpreted as 0 for interface Int32Array.": true, - "The argument -Infinity (2) should be interpreted as 0 for interface Int32Array.": true, - "The argument -4043309056 (10) should be interpreted as 251658240 for interface Int32Array.": true, - "The argument object \"[object Object]\" (18) should be interpreted as 0 for interface Int32Array.": true, - "The argument Infinity (1) should be interpreted as 0 for interface Uint32Array.": true, - "The argument -Infinity (2) should be interpreted as 0 for interface Uint32Array.": true, - "The argument -4043309056 (10) should be interpreted as 251658240 for interface Uint32Array.": true, - "The argument object \"[object Object]\" (18) should be interpreted as 0 for interface Uint32Array.": true, - "The argument Infinity (1) should be interpreted as 0 for interface Float32Array.": true, - "The argument -Infinity (2) should be interpreted as 0 for interface Float32Array.": true, - "The argument -4043309056 (10) should be interpreted as 251658240 for interface Float32Array.": true, - "The argument object \"[object Object]\" (18) should be interpreted as 0 for interface Float32Array.": true, - "The argument Infinity (1) should be interpreted as 0 for interface Float64Array.": true, - "The argument -Infinity (2) should be interpreted as 0 for interface Float64Array.": true, - "The argument -4043309056 (10) should be interpreted as 251658240 for interface Float64Array.": true, - "The argument object \"[object Object]\" (18) should be interpreted as 0 for interface Float64Array.": true -} diff --git a/dom/imptests/html.txt b/dom/imptests/html.txt deleted file mode 100644 index 2d06371d86da..000000000000 --- a/dom/imptests/html.txt +++ /dev/null @@ -1,3 +0,0 @@ -git|git://github.com/w3c/web-platform-tests.git|html -typedarrays -webgl diff --git a/dom/imptests/html/dom/common.js b/dom/imptests/html/dom/common.js deleted file mode 100644 index 817868f3d2bd..000000000000 --- a/dom/imptests/html/dom/common.js +++ /dev/null @@ -1,1087 +0,0 @@ -"use strict"; -// Written by Aryeh Gregor - -// TODO: iframes, contenteditable/designMode - -// Everything is done in functions in this test harness, so we have to declare -// all the variables before use to make sure they can be reused. -var selection; -var testDiv, paras, detachedDiv, detachedPara1, detachedPara2, - foreignDoc, foreignPara1, foreignPara2, xmlDoc, xmlElement, - detachedXmlElement, detachedTextNode, foreignTextNode, - detachedForeignTextNode, xmlTextNode, detachedXmlTextNode, - processingInstruction, detachedProcessingInstruction, comment, - detachedComment, foreignComment, detachedForeignComment, xmlComment, - detachedXmlComment, docfrag, foreignDocfrag, xmlDocfrag, doctype, - foreignDoctype, xmlDoctype; -var testRangesShort, testRanges, testPoints, testNodesShort, testNodes; - -function setupRangeTests() { - selection = getSelection(); - testDiv = document.querySelector("#test"); - if (testDiv) { - testDiv.remove(); - } - testDiv = document.createElement("div"); - testDiv.id = "test"; - document.body.insertBefore(testDiv, document.body.firstChild); - - paras = []; - paras.push(document.createElement("p")); - paras[0].setAttribute("id", "a"); - // Test some diacritics, to make sure browsers are using code units here - // and not something like grapheme clusters. - paras[0].textContent = "A\u0308b\u0308c\u0308d\u0308e\u0308f\u0308g\u0308h\u0308\n"; - testDiv.appendChild(paras[0]); - - paras.push(document.createElement("p")); - paras[1].setAttribute("id", "b"); - paras[1].setAttribute("style", "display:none"); - paras[1].textContent = "Ijklmnop\n"; - testDiv.appendChild(paras[1]); - - paras.push(document.createElement("p")); - paras[2].setAttribute("id", "c"); - paras[2].textContent = "Qrstuvwx"; - testDiv.appendChild(paras[2]); - - paras.push(document.createElement("p")); - paras[3].setAttribute("id", "d"); - paras[3].setAttribute("style", "display:none"); - paras[3].textContent = "Yzabcdef"; - testDiv.appendChild(paras[3]); - - paras.push(document.createElement("p")); - paras[4].setAttribute("id", "e"); - paras[4].setAttribute("style", "display:none"); - paras[4].textContent = "Ghijklmn"; - testDiv.appendChild(paras[4]); - - detachedDiv = document.createElement("div"); - detachedPara1 = document.createElement("p"); - detachedPara1.appendChild(document.createTextNode("Opqrstuv")); - detachedPara2 = document.createElement("p"); - detachedPara2.appendChild(document.createTextNode("Wxyzabcd")); - detachedDiv.appendChild(detachedPara1); - detachedDiv.appendChild(detachedPara2); - - // Opera doesn't automatically create a doctype for a new HTML document, - // contrary to spec. It also doesn't let you add doctypes to documents - // after the fact through any means I've tried. So foreignDoc in Opera - // will have no doctype, foreignDoctype will be null, and Opera will fail - // some tests somewhat mysteriously as a result. - foreignDoc = document.implementation.createHTMLDocument(""); - foreignPara1 = foreignDoc.createElement("p"); - foreignPara1.appendChild(foreignDoc.createTextNode("Efghijkl")); - foreignPara2 = foreignDoc.createElement("p"); - foreignPara2.appendChild(foreignDoc.createTextNode("Mnopqrst")); - foreignDoc.body.appendChild(foreignPara1); - foreignDoc.body.appendChild(foreignPara2); - - // Now we get to do really silly stuff, which nobody in the universe is - // ever going to actually do, but the spec defines behavior, so too bad. - // Testing is fun! - xmlDoctype = document.implementation.createDocumentType("qorflesnorf", "abcde", "x\"'y"); - xmlDoc = document.implementation.createDocument(null, null, xmlDoctype); - detachedXmlElement = xmlDoc.createElement("everyone-hates-hyphenated-element-names"); - detachedTextNode = document.createTextNode("Uvwxyzab"); - detachedForeignTextNode = foreignDoc.createTextNode("Cdefghij"); - detachedXmlTextNode = xmlDoc.createTextNode("Klmnopqr"); - // PIs only exist in XML documents, so don't bother with document or - // foreignDoc. - detachedProcessingInstruction = xmlDoc.createProcessingInstruction("whippoorwill", "chirp chirp chirp"); - detachedComment = document.createComment("Stuvwxyz"); - // Hurrah, we finally got to "z" at the end! - detachedForeignComment = foreignDoc.createComment("אריה יהודה"); - detachedXmlComment = xmlDoc.createComment("בן חיים אליעזר"); - - // We should also test with document fragments that actually contain stuff - // . . . but, maybe later. - docfrag = document.createDocumentFragment(); - foreignDocfrag = foreignDoc.createDocumentFragment(); - xmlDocfrag = xmlDoc.createDocumentFragment(); - - xmlElement = xmlDoc.createElement("igiveuponcreativenames"); - xmlTextNode = xmlDoc.createTextNode("do re mi fa so la ti"); - xmlElement.appendChild(xmlTextNode); - processingInstruction = xmlDoc.createProcessingInstruction("somePI", 'Did you know that ":syn sync fromstart" is very useful when using vim to edit large amounts of JavaScript embedded in HTML?'); - xmlDoc.appendChild(xmlElement); - xmlDoc.appendChild(processingInstruction); - xmlComment = xmlDoc.createComment("I maliciously created a comment that will break incautious XML serializers, but Firefox threw an exception, so all I got was this lousy T-shirt"); - xmlDoc.appendChild(xmlComment); - - comment = document.createComment("Alphabet soup?"); - testDiv.appendChild(comment); - - foreignComment = foreignDoc.createComment('"Commenter" and "commentator" mean different things. I\'ve seen non-native speakers trip up on this.'); - foreignDoc.appendChild(foreignComment); - foreignTextNode = foreignDoc.createTextNode("I admit that I harbor doubts about whether we really need so many things to test, but it's too late to stop now."); - foreignDoc.body.appendChild(foreignTextNode); - - doctype = document.doctype; - foreignDoctype = foreignDoc.doctype; - - testRangesShort = [ - // Various ranges within the text node children of different - // paragraphs. All should be valid. - "[paras[0].firstChild, 0, paras[0].firstChild, 0]", - "[paras[0].firstChild, 0, paras[0].firstChild, 1]", - "[paras[0].firstChild, 2, paras[0].firstChild, 8]", - "[paras[0].firstChild, 2, paras[0].firstChild, 9]", - "[paras[1].firstChild, 0, paras[1].firstChild, 0]", - "[paras[1].firstChild, 2, paras[1].firstChild, 9]", - "[detachedPara1.firstChild, 0, detachedPara1.firstChild, 0]", - "[detachedPara1.firstChild, 2, detachedPara1.firstChild, 8]", - "[foreignPara1.firstChild, 0, foreignPara1.firstChild, 0]", - "[foreignPara1.firstChild, 2, foreignPara1.firstChild, 8]", - // Now try testing some elements, not just text nodes. - "[document.documentElement, 0, document.documentElement, 1]", - "[document.documentElement, 0, document.documentElement, 2]", - "[document.documentElement, 1, document.documentElement, 2]", - "[document.head, 1, document.head, 1]", - "[document.body, 4, document.body, 5]", - "[foreignDoc.documentElement, 0, foreignDoc.documentElement, 1]", - "[paras[0], 0, paras[0], 1]", - "[detachedPara1, 0, detachedPara1, 1]", - // Now try some ranges that span elements. - "[paras[0].firstChild, 0, paras[1].firstChild, 0]", - "[paras[0].firstChild, 0, paras[1].firstChild, 8]", - "[paras[0].firstChild, 3, paras[3], 1]", - // How about something that spans a node and its descendant? - "[paras[0], 0, paras[0].firstChild, 7]", - "[testDiv, 2, paras[4], 1]", - // Then a few more interesting things just for good measure. - "[document, 0, document, 1]", - "[document, 0, document, 2]", - "[comment, 2, comment, 3]", - "[testDiv, 0, comment, 5]", - "[foreignDoc, 1, foreignComment, 2]", - "[foreignDoc.body, 0, foreignTextNode, 36]", - "[xmlDoc, 1, xmlComment, 0]", - "[detachedTextNode, 0, detachedTextNode, 8]", - "[detachedForeignTextNode, 0, detachedForeignTextNode, 8]", - "[detachedXmlTextNode, 0, detachedXmlTextNode, 8]", - "[detachedComment, 3, detachedComment, 4]", - "[detachedForeignComment, 0, detachedForeignComment, 1]", - "[detachedXmlComment, 2, detachedXmlComment, 6]", - "[docfrag, 0, docfrag, 0]", - ]; - - testRanges = testRangesShort.concat([ - "[paras[1].firstChild, 0, paras[1].firstChild, 1]", - "[paras[1].firstChild, 2, paras[1].firstChild, 8]", - "[detachedPara1.firstChild, 0, detachedPara1.firstChild, 1]", - "[foreignPara1.firstChild, 0, foreignPara1.firstChild, 1]", - "[foreignDoc.head, 1, foreignDoc.head, 1]", - "[foreignDoc.body, 0, foreignDoc.body, 0]", - "[paras[0], 0, paras[0], 0]", - "[detachedPara1, 0, detachedPara1, 0]", - "[testDiv, 1, paras[2].firstChild, 5]", - "[document.documentElement, 1, document.body, 0]", - "[foreignDoc.documentElement, 1, foreignDoc.body, 0]", - "[document, 1, document, 2]", - "[paras[2].firstChild, 4, comment, 2]", - "[paras[3], 1, comment, 8]", - "[foreignDoc, 0, foreignDoc, 0]", - "[xmlDoc, 0, xmlDoc, 0]", - "[detachedForeignTextNode, 7, detachedForeignTextNode, 7]", - "[detachedXmlTextNode, 7, detachedXmlTextNode, 7]", - "[detachedComment, 5, detachedComment, 5]", - "[detachedForeignComment, 4, detachedForeignComment, 4]", - "[foreignDocfrag, 0, foreignDocfrag, 0]", - "[xmlDocfrag, 0, xmlDocfrag, 0]", - ]); - - testPoints = [ - // Various positions within the page, some invalid. Remember that - // paras[0] is visible, and paras[1] is display: none. - "[paras[0].firstChild, -1]", - "[paras[0].firstChild, 0]", - "[paras[0].firstChild, 1]", - "[paras[0].firstChild, 2]", - "[paras[0].firstChild, 8]", - "[paras[0].firstChild, 9]", - "[paras[0].firstChild, 10]", - "[paras[0].firstChild, 65535]", - "[paras[1].firstChild, -1]", - "[paras[1].firstChild, 0]", - "[paras[1].firstChild, 1]", - "[paras[1].firstChild, 2]", - "[paras[1].firstChild, 8]", - "[paras[1].firstChild, 9]", - "[paras[1].firstChild, 10]", - "[paras[1].firstChild, 65535]", - "[detachedPara1.firstChild, 0]", - "[detachedPara1.firstChild, 1]", - "[detachedPara1.firstChild, 8]", - "[detachedPara1.firstChild, 9]", - "[foreignPara1.firstChild, 0]", - "[foreignPara1.firstChild, 1]", - "[foreignPara1.firstChild, 8]", - "[foreignPara1.firstChild, 9]", - // Now try testing some elements, not just text nodes. - "[document.documentElement, -1]", - "[document.documentElement, 0]", - "[document.documentElement, 1]", - "[document.documentElement, 2]", - "[document.documentElement, 7]", - "[document.head, 1]", - "[document.body, 3]", - "[foreignDoc.documentElement, 0]", - "[foreignDoc.documentElement, 1]", - "[foreignDoc.head, 0]", - "[foreignDoc.body, 1]", - "[paras[0], 0]", - "[paras[0], 1]", - "[paras[0], 2]", - "[paras[1], 0]", - "[paras[1], 1]", - "[paras[1], 2]", - "[detachedPara1, 0]", - "[detachedPara1, 1]", - "[testDiv, 0]", - "[testDiv, 3]", - // Then a few more interesting things just for good measure. - "[document, -1]", - "[document, 0]", - "[document, 1]", - "[document, 2]", - "[document, 3]", - "[comment, -1]", - "[comment, 0]", - "[comment, 4]", - "[comment, 96]", - "[foreignDoc, 0]", - "[foreignDoc, 1]", - "[foreignComment, 2]", - "[foreignTextNode, 0]", - "[foreignTextNode, 36]", - "[xmlDoc, -1]", - "[xmlDoc, 0]", - "[xmlDoc, 1]", - "[xmlDoc, 5]", - "[xmlComment, 0]", - "[xmlComment, 4]", - "[processingInstruction, 0]", - "[processingInstruction, 5]", - "[processingInstruction, 9]", - "[detachedTextNode, 0]", - "[detachedTextNode, 8]", - "[detachedForeignTextNode, 0]", - "[detachedForeignTextNode, 8]", - "[detachedXmlTextNode, 0]", - "[detachedXmlTextNode, 8]", - "[detachedProcessingInstruction, 12]", - "[detachedComment, 3]", - "[detachedComment, 5]", - "[detachedForeignComment, 0]", - "[detachedForeignComment, 4]", - "[detachedXmlComment, 2]", - "[docfrag, 0]", - "[foreignDocfrag, 0]", - "[xmlDocfrag, 0]", - "[doctype, 0]", - "[doctype, -17]", - "[doctype, 1]", - "[foreignDoctype, 0]", - "[xmlDoctype, 0]", - ]; - - testNodesShort = [ - "paras[0]", - "paras[0].firstChild", - "paras[1].firstChild", - "foreignPara1", - "foreignPara1.firstChild", - "detachedPara1", - "detachedPara1.firstChild", - "document", - "detachedDiv", - "foreignDoc", - "foreignPara2", - "xmlDoc", - "xmlElement", - "detachedTextNode", - "foreignTextNode", - "processingInstruction", - "detachedProcessingInstruction", - "comment", - "detachedComment", - "docfrag", - "doctype", - "foreignDoctype", - ]; - - testNodes = testNodesShort.concat([ - "paras[1]", - "detachedPara2", - "detachedPara2.firstChild", - "testDiv", - "detachedXmlElement", - "detachedForeignTextNode", - "xmlTextNode", - "detachedXmlTextNode", - "xmlComment", - "foreignComment", - "detachedForeignComment", - "detachedXmlComment", - "foreignDocfrag", - "xmlDocfrag", - "xmlDoctype", - ]); -} -if ("setup" in window) { - setup(setupRangeTests); -} else { - // Presumably we're running from within an iframe or something - setupRangeTests(); -} - -/** - * The "length" of a node as defined by the Ranges section of DOM4. - */ -function nodeLength(node) { - // "The length of a node node depends on node: - // - // "DocumentType - // "0." - if (node.nodeType == Node.DOCUMENT_TYPE_NODE) { - return 0; - } - // "Text - // "ProcessingInstruction - // "Comment - // "Its length attribute value." - // Browsers don't historically support the length attribute on - // ProcessingInstruction, so to avoid spurious failures, do - // node.data.length instead of node.length. - if (node.nodeType == Node.TEXT_NODE || node.nodeType == Node.PROCESSING_INSTRUCTION_NODE || node.nodeType == Node.COMMENT_NODE) { - return node.data.length; - } - // "Any other node - // "Its number of children." - return node.childNodes.length; -} - -/** - * Returns the furthest ancestor of a Node as defined by the spec. - */ -function furthestAncestor(node) { - var root = node; - while (root.parentNode != null) { - root = root.parentNode; - } - return root; -} - -/** - * "The ancestor containers of a Node are the Node itself and all its - * ancestors." - * - * Is node1 an ancestor container of node2? - */ -function isAncestorContainer(node1, node2) { - return node1 == node2 || - (node2.compareDocumentPosition(node1) & Node.DOCUMENT_POSITION_CONTAINS); -} - -/** - * Returns the first Node that's after node in tree order, or null if node is - * the last Node. - */ -function nextNode(node) { - if (node.hasChildNodes()) { - return node.firstChild; - } - return nextNodeDescendants(node); -} - -/** - * Returns the last Node that's before node in tree order, or null if node is - * the first Node. - */ -function previousNode(node) { - if (node.previousSibling) { - node = node.previousSibling; - while (node.hasChildNodes()) { - node = node.lastChild; - } - return node; - } - return node.parentNode; -} - -/** - * Returns the next Node that's after node and all its descendants in tree - * order, or null if node is the last Node or an ancestor of it. - */ -function nextNodeDescendants(node) { - while (node && !node.nextSibling) { - node = node.parentNode; - } - if (!node) { - return null; - } - return node.nextSibling; -} - -/** - * Returns the ownerDocument of the Node, or the Node itself if it's a - * Document. - */ -function ownerDocument(node) { - return node.nodeType == Node.DOCUMENT_NODE - ? node - : node.ownerDocument; -} - -/** - * Returns true if ancestor is an ancestor of descendant, false otherwise. - */ -function isAncestor(ancestor, descendant) { - if (!ancestor || !descendant) { - return false; - } - while (descendant && descendant != ancestor) { - descendant = descendant.parentNode; - } - return descendant == ancestor; -} - -/** - * Returns true if ancestor is an inclusive ancestor of descendant, false - * otherwise. - */ -function isInclusiveAncestor(ancestor, descendant) { - return ancestor === descendant || isAncestor(ancestor, descendant); -} - -/** - * Returns true if descendant is a descendant of ancestor, false otherwise. - */ -function isDescendant(descendant, ancestor) { - return isAncestor(ancestor, descendant); -} - -/** - * Returns true if descendant is an inclusive descendant of ancestor, false - * otherwise. - */ -function isInclusiveDescendant(descendant, ancestor) { - return descendant === ancestor || isDescendant(descendant, ancestor); -} - -/** - * The position of two boundary points relative to one another, as defined by - * the spec. - */ -function getPosition(nodeA, offsetA, nodeB, offsetB) { - // "If node A is the same as node B, return equal if offset A equals offset - // B, before if offset A is less than offset B, and after if offset A is - // greater than offset B." - if (nodeA == nodeB) { - if (offsetA == offsetB) { - return "equal"; - } - if (offsetA < offsetB) { - return "before"; - } - if (offsetA > offsetB) { - return "after"; - } - } - - // "If node A is after node B in tree order, compute the position of (node - // B, offset B) relative to (node A, offset A). If it is before, return - // after. If it is after, return before." - if (nodeB.compareDocumentPosition(nodeA) & Node.DOCUMENT_POSITION_FOLLOWING) { - var pos = getPosition(nodeB, offsetB, nodeA, offsetA); - if (pos == "before") { - return "after"; - } - if (pos == "after") { - return "before"; - } - } - - // "If node A is an ancestor of node B:" - if (nodeB.compareDocumentPosition(nodeA) & Node.DOCUMENT_POSITION_CONTAINS) { - // "Let child equal node B." - var child = nodeB; - - // "While child is not a child of node A, set child to its parent." - while (child.parentNode != nodeA) { - child = child.parentNode; - } - - // "If the index of child is less than offset A, return after." - if (indexOf(child) < offsetA) { - return "after"; - } - } - - // "Return before." - return "before"; -} - -/** - * "contained" as defined by DOM Range: "A Node node is contained in a range - * range if node's furthest ancestor is the same as range's root, and (node, 0) - * is after range's start, and (node, length of node) is before range's end." - */ -function isContained(node, range) { - var pos1 = getPosition(node, 0, range.startContainer, range.startOffset); - var pos2 = getPosition(node, nodeLength(node), range.endContainer, range.endOffset); - - return furthestAncestor(node) == furthestAncestor(range.startContainer) - && pos1 == "after" - && pos2 == "before"; -} - -/** - * "partially contained" as defined by DOM Range: "A Node is partially - * contained in a range if it is an ancestor container of the range's start but - * not its end, or vice versa." - */ -function isPartiallyContained(node, range) { - var cond1 = isAncestorContainer(node, range.startContainer); - var cond2 = isAncestorContainer(node, range.endContainer); - return (cond1 && !cond2) || (cond2 && !cond1); -} - -/** - * Index of a node as defined by the spec. - */ -function indexOf(node) { - if (!node.parentNode) { - // No preceding sibling nodes, right? - return 0; - } - var i = 0; - while (node != node.parentNode.childNodes[i]) { - i++; - } - return i; -} - -/** - * extractContents() implementation, following the spec. If an exception is - * supposed to be thrown, will return a string with the name (e.g., - * "HIERARCHY_REQUEST_ERR") instead of a document fragment. It might also - * return an arbitrary human-readable string if a condition is hit that implies - * a spec bug. - */ -function myExtractContents(range) { - // "If the context object's detached flag is set, raise an - // INVALID_STATE_ERR exception and abort these steps." - try { - range.collapsed; - } catch (e) { - return "INVALID_STATE_ERR"; - } - - // "Let frag be a new DocumentFragment whose ownerDocument is the same as - // the ownerDocument of the context object's start node." - var ownerDoc = range.startContainer.nodeType == Node.DOCUMENT_NODE - ? range.startContainer - : range.startContainer.ownerDocument; - var frag = ownerDoc.createDocumentFragment(); - - // "If the context object's start and end are the same, abort this method, - // returning frag." - if (range.startContainer == range.endContainer - && range.startOffset == range.endOffset) { - return frag; - } - - // "Let original start node, original start offset, original end node, and - // original end offset be the context object's start and end nodes and - // offsets, respectively." - var originalStartNode = range.startContainer; - var originalStartOffset = range.startOffset; - var originalEndNode = range.endContainer; - var originalEndOffset = range.endOffset; - - // "If original start node and original end node are the same, and they are - // a Text or Comment node:" - if (range.startContainer == range.endContainer - && (range.startContainer.nodeType == Node.TEXT_NODE - || range.startContainer.nodeType == Node.COMMENT_NODE)) { - // "Let clone be the result of calling cloneNode(false) on original - // start node." - var clone = originalStartNode.cloneNode(false); - - // "Set the data of clone to the result of calling - // substringData(original start offset, original end offset − original - // start offset) on original start node." - clone.data = originalStartNode.substringData(originalStartOffset, - originalEndOffset - originalStartOffset); - - // "Append clone as the last child of frag." - frag.appendChild(clone); - - // "Call deleteData(original start offset, original end offset − - // original start offset) on original start node." - originalStartNode.deleteData(originalStartOffset, - originalEndOffset - originalStartOffset); - - // "Abort this method, returning frag." - return frag; - } - - // "Let common ancestor equal original start node." - var commonAncestor = originalStartNode; - - // "While common ancestor is not an ancestor container of original end - // node, set common ancestor to its own parent." - while (!isAncestorContainer(commonAncestor, originalEndNode)) { - commonAncestor = commonAncestor.parentNode; - } - - // "If original start node is an ancestor container of original end node, - // let first partially contained child be null." - var firstPartiallyContainedChild; - if (isAncestorContainer(originalStartNode, originalEndNode)) { - firstPartiallyContainedChild = null; - // "Otherwise, let first partially contained child be the first child of - // common ancestor that is partially contained in the context object." - } else { - for (var i = 0; i < commonAncestor.childNodes.length; i++) { - if (isPartiallyContained(commonAncestor.childNodes[i], range)) { - firstPartiallyContainedChild = commonAncestor.childNodes[i]; - break; - } - } - if (!firstPartiallyContainedChild) { - throw "Spec bug: no first partially contained child!"; - } - } - - // "If original end node is an ancestor container of original start node, - // let last partially contained child be null." - var lastPartiallyContainedChild; - if (isAncestorContainer(originalEndNode, originalStartNode)) { - lastPartiallyContainedChild = null; - // "Otherwise, let last partially contained child be the last child of - // common ancestor that is partially contained in the context object." - } else { - for (var i = commonAncestor.childNodes.length - 1; i >= 0; i--) { - if (isPartiallyContained(commonAncestor.childNodes[i], range)) { - lastPartiallyContainedChild = commonAncestor.childNodes[i]; - break; - } - } - if (!lastPartiallyContainedChild) { - throw "Spec bug: no last partially contained child!"; - } - } - - // "Let contained children be a list of all children of common ancestor - // that are contained in the context object, in tree order." - // - // "If any member of contained children is a DocumentType, raise a - // HIERARCHY_REQUEST_ERR exception and abort these steps." - var containedChildren = []; - for (var i = 0; i < commonAncestor.childNodes.length; i++) { - if (isContained(commonAncestor.childNodes[i], range)) { - if (commonAncestor.childNodes[i].nodeType - == Node.DOCUMENT_TYPE_NODE) { - return "HIERARCHY_REQUEST_ERR"; - } - containedChildren.push(commonAncestor.childNodes[i]); - } - } - - // "If original start node is an ancestor container of original end node, - // set new node to original start node and new offset to original start - // offset." - var newNode, newOffset; - if (isAncestorContainer(originalStartNode, originalEndNode)) { - newNode = originalStartNode; - newOffset = originalStartOffset; - // "Otherwise:" - } else { - // "Let reference node equal original start node." - var referenceNode = originalStartNode; - - // "While reference node's parent is not null and is not an ancestor - // container of original end node, set reference node to its parent." - while (referenceNode.parentNode - && !isAncestorContainer(referenceNode.parentNode, originalEndNode)) { - referenceNode = referenceNode.parentNode; - } - - // "Set new node to the parent of reference node, and new offset to one - // plus the index of reference node." - newNode = referenceNode.parentNode; - newOffset = 1 + indexOf(referenceNode); - } - - // "If first partially contained child is a Text or Comment node:" - if (firstPartiallyContainedChild - && (firstPartiallyContainedChild.nodeType == Node.TEXT_NODE - || firstPartiallyContainedChild.nodeType == Node.COMMENT_NODE)) { - // "Let clone be the result of calling cloneNode(false) on original - // start node." - var clone = originalStartNode.cloneNode(false); - - // "Set the data of clone to the result of calling substringData() on - // original start node, with original start offset as the first - // argument and (length of original start node − original start offset) - // as the second." - clone.data = originalStartNode.substringData(originalStartOffset, - nodeLength(originalStartNode) - originalStartOffset); - - // "Append clone as the last child of frag." - frag.appendChild(clone); - - // "Call deleteData() on original start node, with original start - // offset as the first argument and (length of original start node − - // original start offset) as the second." - originalStartNode.deleteData(originalStartOffset, - nodeLength(originalStartNode) - originalStartOffset); - // "Otherwise, if first partially contained child is not null:" - } else if (firstPartiallyContainedChild) { - // "Let clone be the result of calling cloneNode(false) on first - // partially contained child." - var clone = firstPartiallyContainedChild.cloneNode(false); - - // "Append clone as the last child of frag." - frag.appendChild(clone); - - // "Let subrange be a new Range whose start is (original start node, - // original start offset) and whose end is (first partially contained - // child, length of first partially contained child)." - var subrange = ownerDoc.createRange(); - subrange.setStart(originalStartNode, originalStartOffset); - subrange.setEnd(firstPartiallyContainedChild, - nodeLength(firstPartiallyContainedChild)); - - // "Let subfrag be the result of calling extractContents() on - // subrange." - var subfrag = myExtractContents(subrange); - - // "For each child of subfrag, in order, append that child to clone as - // its last child." - for (var i = 0; i < subfrag.childNodes.length; i++) { - clone.appendChild(subfrag.childNodes[i]); - } - } - - // "For each contained child in contained children, append contained child - // as the last child of frag." - for (var i = 0; i < containedChildren.length; i++) { - frag.appendChild(containedChildren[i]); - } - - // "If last partially contained child is a Text or Comment node:" - if (lastPartiallyContainedChild - && (lastPartiallyContainedChild.nodeType == Node.TEXT_NODE - || lastPartiallyContainedChild.nodeType == Node.COMMENT_NODE)) { - // "Let clone be the result of calling cloneNode(false) on original - // end node." - var clone = originalEndNode.cloneNode(false); - - // "Set the data of clone to the result of calling substringData(0, - // original end offset) on original end node." - clone.data = originalEndNode.substringData(0, originalEndOffset); - - // "Append clone as the last child of frag." - frag.appendChild(clone); - - // "Call deleteData(0, original end offset) on original end node." - originalEndNode.deleteData(0, originalEndOffset); - // "Otherwise, if last partially contained child is not null:" - } else if (lastPartiallyContainedChild) { - // "Let clone be the result of calling cloneNode(false) on last - // partially contained child." - var clone = lastPartiallyContainedChild.cloneNode(false); - - // "Append clone as the last child of frag." - frag.appendChild(clone); - - // "Let subrange be a new Range whose start is (last partially - // contained child, 0) and whose end is (original end node, original - // end offset)." - var subrange = ownerDoc.createRange(); - subrange.setStart(lastPartiallyContainedChild, 0); - subrange.setEnd(originalEndNode, originalEndOffset); - - // "Let subfrag be the result of calling extractContents() on - // subrange." - var subfrag = myExtractContents(subrange); - - // "For each child of subfrag, in order, append that child to clone as - // its last child." - for (var i = 0; i < subfrag.childNodes.length; i++) { - clone.appendChild(subfrag.childNodes[i]); - } - } - - // "Set the context object's start and end to (new node, new offset)." - range.setStart(newNode, newOffset); - range.setEnd(newNode, newOffset); - - // "Return frag." - return frag; -} - -/** - * insertNode() implementation, following the spec. If an exception is meant - * to be thrown, will return a string with the expected exception name, for - * instance "HIERARCHY_REQUEST_ERR". - */ -function myInsertNode(range, node) { - // "If range's start node is either a ProcessingInstruction or Comment - // node, or a Text node whose parent is null, throw an - // "HierarchyRequestError" exception and terminate these steps." - if (range.startContainer.nodeType == Node.PROCESSING_INSTRUCTION_NODE - || range.startContainer.nodeType == Node.COMMENT_NODE - || (range.startContainer.nodeType == Node.TEXT_NODE - && !range.startContainer.parentNode)) { - return "HIERARCHY_REQUEST_ERR"; - } - - // "Let referenceNode be null." - var referenceNode = null; - - // "If range's start node is a Text node, set referenceNode to that Text node." - if (range.startContainer.nodeType == Node.TEXT_NODE) { - referenceNode = range.startContainer; - - // "Otherwise, set referenceNode to the child of start node whose index is - // start offset, and null if there is no such child." - } else { - if (range.startOffset < range.startContainer.childNodes.length) { - referenceNode = range.startContainer.childNodes[range.startOffset]; - } else { - referenceNode = null; - } - } - - // "Let parent be range's start node if referenceNode is null, and - // referenceNode's parent otherwise." - var parent_ = referenceNode === null ? range.startContainer : - referenceNode.parentNode; - - // "Ensure pre-insertion validity of node into parent before - // referenceNode." - var error = ensurePreInsertionValidity(node, parent_, referenceNode); - if (error) { - return error; - } - - // "If range's start node is a Text node, set referenceNode to the result - // of splitting it with offset range's start offset." - if (range.startContainer.nodeType == Node.TEXT_NODE) { - referenceNode = range.startContainer.splitText(range.startOffset); - } - - // "If node is referenceNode, set referenceNode to its next sibling." - if (node == referenceNode) { - referenceNode = referenceNode.nextSibling; - } - - // "If node's parent is not null, remove node from its parent." - if (node.parentNode) { - node.remove(); - } - - // "Let newOffset be parent's length if referenceNode is null, and - // referenceNode's index otherwise." - var newOffset = referenceNode === null ? nodeLength(parent_) : - indexOf(referenceNode); - - // "Increase newOffset by node's length if node is a DocumentFragment node, - // and one otherwise." - newOffset += node.nodeType == Node.DOCUMENT_FRAGMENT_NODE ? - nodeLength(node) : 1; - - // "Pre-insert node into parent before referenceNode." - parent_.insertBefore(node, referenceNode); - - // "If range's start and end are the same, set range's end to (parent, - // newOffset)." - if (range.startContainer == range.endContainer - && range.startOffset == range.endOffset) { - range.setEnd(parent_, newOffset); - } -} - -// To make filter() calls more readable -function isElement(node) { - return node.nodeType == Node.ELEMENT_NODE; -} - -function isText(node) { - return node.nodeType == Node.TEXT_NODE; -} - -function isDoctype(node) { - return node.nodeType == Node.DOCUMENT_TYPE_NODE; -} - -function ensurePreInsertionValidity(node, parent_, child) { - // "If parent is not a Document, DocumentFragment, or Element node, throw a - // HierarchyRequestError." - if (parent_.nodeType != Node.DOCUMENT_NODE - && parent_.nodeType != Node.DOCUMENT_FRAGMENT_NODE - && parent_.nodeType != Node.ELEMENT_NODE) { - return "HIERARCHY_REQUEST_ERR"; - } - - // "If node is a host-including inclusive ancestor of parent, throw a - // HierarchyRequestError." - // - // XXX Does not account for host - if (isInclusiveAncestor(node, parent_)) { - return "HIERARCHY_REQUEST_ERR"; - } - - // "If child is not null and its parent is not parent, throw a NotFoundError - // exception." - if (child && child.parentNode != parent_) { - return "NOT_FOUND_ERR"; - } - - // "If node is not a DocumentFragment, DocumentType, Element, Text, - // ProcessingInstruction, or Comment node, throw a HierarchyRequestError." - if (node.nodeType != Node.DOCUMENT_FRAGMENT_NODE - && node.nodeType != Node.DOCUMENT_TYPE_NODE - && node.nodeType != Node.ELEMENT_NODE - && node.nodeType != Node.TEXT_NODE - && node.nodeType != Node.PROCESSING_INSTRUCTION_NODE - && node.nodeType != Node.COMMENT_NODE) { - return "HIERARCHY_REQUEST_ERR"; - } - - // "If either node is a Text node and parent is a document, or node is a - // doctype and parent is not a document, throw a HierarchyRequestError." - if ((node.nodeType == Node.TEXT_NODE - && parent_.nodeType == Node.DOCUMENT_NODE) - || (node.nodeType == Node.DOCUMENT_TYPE_NODE - && parent_.nodeType != Node.DOCUMENT_NODE)) { - return "HIERARCHY_REQUEST_ERR"; - } - - // "If parent is a document, and any of the statements below, switched on - // node, are true, throw a HierarchyRequestError." - if (parent_.nodeType == Node.DOCUMENT_NODE) { - switch (node.nodeType) { - case Node.DOCUMENT_FRAGMENT_NODE: - // "If node has more than one element child or has a Text node - // child. Otherwise, if node has one element child and either - // parent has an element child, child is a doctype, or child is not - // null and a doctype is following child." - if ([].filter.call(node.childNodes, isElement).length > 1) { - return "HIERARCHY_REQUEST_ERR"; - } - - if ([].some.call(node.childNodes, isText)) { - return "HIERARCHY_REQUEST_ERR"; - } - - if ([].filter.call(node.childNodes, isElement).length == 1) { - if ([].some.call(parent_.childNodes, isElement)) { - return "HIERARCHY_REQUEST_ERR"; - } - - if (child && child.nodeType == Node.DOCUMENT_TYPE_NODE) { - return "HIERARCHY_REQUEST_ERR"; - } - - if (child && [].slice.call(parent_.childNodes, indexOf(child) + 1) - .filter(isDoctype)) { - return "HIERARCHY_REQUEST_ERR"; - } - } - break; - - case Node.ELEMENT_NODE: - // "parent has an element child, child is a doctype, or child is - // not null and a doctype is following child." - if ([].some.call(parent_.childNodes, isElement)) { - return "HIERARCHY_REQUEST_ERR"; - } - - if (child.nodeType == Node.DOCUMENT_TYPE_NODE) { - return "HIERARCHY_REQUEST_ERR"; - } - - if (child && [].slice.call(parent_.childNodes, indexOf(child) + 1) - .filter(isDoctype)) { - return "HIERARCHY_REQUEST_ERR"; - } - break; - - case Node.DOCUMENT_TYPE_NODE: - // "parent has a doctype child, an element is preceding child, or - // child is null and parent has an element child." - if ([].some.call(parent_.childNodes, isDoctype)) { - return "HIERARCHY_REQUEST_ERR"; - } - - if (child && [].slice.call(parent_.childNodes, 0, indexOf(child)) - .some(isElement)) { - return "HIERARCHY_REQUEST_ERR"; - } - - if (!child && [].some.call(parent_.childNodes, isElement)) { - return "HIERARCHY_REQUEST_ERR"; - } - break; - } - } -} - -/** - * Asserts that two nodes are equal, in the sense of isEqualNode(). If they - * aren't, tries to print a relatively informative reason why not. TODO: Move - * this to testharness.js? - */ -function assertNodesEqual(actual, expected, msg) { - if (!actual.isEqualNode(expected)) { - msg = "Actual and expected mismatch for " + msg + ". "; - - while (actual && expected) { - assert_true(actual.nodeType === expected.nodeType - && actual.nodeName === expected.nodeName - && actual.nodeValue === expected.nodeValue - && actual.childNodes.length === expected.childNodes.length, - "First differing node: expected " + format_value(expected) - + ", got " + format_value(actual)); - actual = nextNode(actual); - expected = nextNode(expected); - } - - assert_unreached("DOMs were not equal but we couldn't figure out why"); - } -} - -/** - * Given a DOMException, return the name (e.g., "HIERARCHY_REQUEST_ERR"). - */ -function getDomExceptionName(e) { - var ret = null; - for (var prop in e) { - if (/^[A-Z_]+_ERR$/.test(prop) && e[prop] == e.code) { - return prop; - } - } - - throw "Exception seems to not be a DOMException? " + e; -} - -/** - * Given an array of endpoint data [start container, start offset, end - * container, end offset], returns a Range with those endpoints. - */ -function rangeFromEndpoints(endpoints) { - // If we just use document instead of the ownerDocument of endpoints[0], - // WebKit will throw on setStart/setEnd. This is a WebKit bug, but it's in - // range, not selection, so we don't want to fail anything for it. - var range = ownerDocument(endpoints[0]).createRange(); - range.setStart(endpoints[0], endpoints[1]); - range.setEnd(endpoints[2], endpoints[3]); - return range; -} diff --git a/dom/imptests/html/dom/test_interface-objects.html b/dom/imptests/html/dom/test_interface-objects.html deleted file mode 100644 index 0e2bf1acdda4..000000000000 --- a/dom/imptests/html/dom/test_interface-objects.html +++ /dev/null @@ -1,45 +0,0 @@ - -Interfaces - - -
- diff --git a/dom/imptests/html/dom/test_interfaces.html b/dom/imptests/html/dom/test_interfaces.html deleted file mode 100644 index e95d6f87e2b7..000000000000 --- a/dom/imptests/html/dom/test_interfaces.html +++ /dev/null @@ -1,455 +0,0 @@ - - -DOM IDL tests - - - - - -

DOM IDL tests

-
- - - diff --git a/dom/imptests/html/html/browsers/the-window-object/test_window-named-properties.html b/dom/imptests/html/html/browsers/the-window-object/test_window-named-properties.html deleted file mode 100644 index b01e24da9888..000000000000 --- a/dom/imptests/html/html/browsers/the-window-object/test_window-named-properties.html +++ /dev/null @@ -1,69 +0,0 @@ - - -Changes to named properties of the window object - - - - - - - -
- - - diff --git a/dom/imptests/html/html/dom/documents/dta/test_nameditem-06.html b/dom/imptests/html/html/dom/documents/dta/test_nameditem-06.html deleted file mode 100644 index 3fd3d474a4eb..000000000000 --- a/dom/imptests/html/html/dom/documents/dta/test_nameditem-06.html +++ /dev/null @@ -1,104 +0,0 @@ - - -Named items: imgs - - - - -
-
- - - - - - - - - - - - - - - - - - - -
- diff --git a/dom/imptests/html/html/dom/elements/global-attributes/reftest.list b/dom/imptests/html/html/dom/elements/global-attributes/reftest.list deleted file mode 100644 index a58929e92174..000000000000 --- a/dom/imptests/html/html/dom/elements/global-attributes/reftest.list +++ /dev/null @@ -1,56 +0,0 @@ -# THIS FILE IS AUTOGENERATED BY importTestsuite.py - DO NOT EDIT - -== dir_auto-contained-bdi-L.html dir_auto-contained-bdi-L-ref.html -== dir_auto-contained-bdi-R.html dir_auto-contained-bdi-R-ref.html -== dir_auto-contained-dir_auto-L.html dir_auto-contained-dir_auto-L-ref.html -== dir_auto-contained-dir_auto-R.html dir_auto-contained-dir_auto-R-ref.html -== dir_auto-contained-dir-L.html dir_auto-contained-dir-L-ref.html -== dir_auto-contained-dir-R.html dir_auto-contained-dir-R-ref.html -== dir_auto-contained-L.html dir_auto-contained-L-ref.html -== dir_auto-contained-R.html dir_auto-contained-R-ref.html -== dir_auto-contained-script-L.html dir_auto-contained-script-L-ref.html -== dir_auto-contained-script-R.html dir_auto-contained-script-R-ref.html -== dir_auto-contained-style-L.html dir_auto-contained-style-L-ref.html -== dir_auto-contained-style-R.html dir_auto-contained-style-R-ref.html -== dir_auto-contained-textarea-L.html dir_auto-contained-textarea-L-ref.html -== dir_auto-contained-textarea-R.html dir_auto-contained-textarea-R-ref.html -== dir_auto-EN-L.html dir_auto-EN-L-ref.html -== dir_auto-EN-R.html dir_auto-EN-R-ref.html -== dir_auto-input-EN-L.html dir_auto-input-EN-L-ref.html -== dir_auto-input-EN-R.html dir_auto-input-EN-R-ref.html -== dir_auto-input-L.html dir_auto-input-L-ref.html -== dir_auto-input-N-EN.html dir_auto-input-N-EN-ref.html -== dir_auto-input-N-EN-L.html dir_auto-input-N-EN-L-ref.html -== dir_auto-input-N-EN-R.html dir_auto-input-N-EN-R-ref.html -== dir_auto-input-N-L.html dir_auto-input-N-L-ref.html -== dir_auto-input-N-R.html dir_auto-input-N-R-ref.html -== dir_auto-input-R.html dir_auto-input-R-ref.html -== dir_auto-input-script-EN-L.html dir_auto-input-script-EN-L-ref.html -== dir_auto-input-script-EN-R.html dir_auto-input-script-EN-R-ref.html -== dir_auto-input-script-L.html dir_auto-input-script-L-ref.html -== dir_auto-input-script-N-EN.html dir_auto-input-script-N-EN-ref.html -== dir_auto-input-script-N-EN-L.html dir_auto-input-script-N-EN-L-ref.html -== dir_auto-input-script-N-EN-R.html dir_auto-input-script-N-EN-R-ref.html -== dir_auto-input-script-N-L.html dir_auto-input-script-N-L-ref.html -== dir_auto-input-script-N-R.html dir_auto-input-script-N-R-ref.html -== dir_auto-input-script-R.html dir_auto-input-script-R-ref.html -== dir_auto-isolate.html dir_auto-isolate-ref.html -== dir_auto-L.html dir_auto-L-ref.html -== dir_auto-N-EN.html dir_auto-N-EN-ref.html -== dir_auto-N-EN-L.html dir_auto-N-EN-L-ref.html -== dir_auto-N-EN-R.html dir_auto-N-EN-R-ref.html -== dir_auto-N-L.html dir_auto-N-L-ref.html -== dir_auto-N-R.html dir_auto-N-R-ref.html -== dir_auto-pre-mixed.html dir_auto-pre-mixed-ref.html -== dir_auto-pre-N-between-Rs.html dir_auto-pre-N-between-Rs-ref.html -== dir_auto-pre-N-EN.html dir_auto-pre-N-EN-ref.html -== dir_auto-R.html dir_auto-R-ref.html -== dir_auto-textarea-mixed.html dir_auto-textarea-mixed-ref.html -fails-if(Android&&asyncPan) == dir_auto-textarea-N-between-Rs.html dir_auto-textarea-N-between-Rs-ref.html -== dir_auto-textarea-N-EN.html dir_auto-textarea-N-EN-ref.html -== dir_auto-textarea-script-mixed.html dir_auto-textarea-script-mixed-ref.html -fails-if(Android&&asyncPan) == dir_auto-textarea-script-N-between-Rs.html dir_auto-textarea-script-N-between-Rs-ref.html -== dir_auto-textarea-script-N-EN.html dir_auto-textarea-script-N-EN-ref.html -== lang-xyzzy.html lang-xyzzy-ref.html -== lang-xmllang-01.html lang-xmllang-01-ref.html -== style-01.html style-01-ref.html diff --git a/dom/imptests/html/js/builtins/test_WeakMap.prototype-properties.html b/dom/imptests/html/js/builtins/test_WeakMap.prototype-properties.html deleted file mode 100644 index 0bdb6bb86d1e..000000000000 --- a/dom/imptests/html/js/builtins/test_WeakMap.prototype-properties.html +++ /dev/null @@ -1,103 +0,0 @@ - -WeakMap.prototype - - - - -
- diff --git a/dom/imptests/html/mochitest.ini b/dom/imptests/html/mochitest.ini deleted file mode 100644 index 87b958f0e4b1..000000000000 --- a/dom/imptests/html/mochitest.ini +++ /dev/null @@ -1,24 +0,0 @@ -# THIS FILE IS AUTOGENERATED BY importTestsuite.py - DO NOT EDIT -[DEFAULT] -support-files = - webgl/common.js - -[typedarrays/test_constructors.html] -[webgl/test_bufferSubData.html] -subsuite = gpu -skip-if = toolkit == 'android' #android(WebGL) -[webgl/test_compressedTexImage2D.html] -subsuite = gpu -skip-if = toolkit == 'android' #android(WebGL) -[webgl/test_compressedTexSubImage2D.html] -subsuite = gpu -skip-if = true # Bug 1226336 -[webgl/test_texImage2D.html] -subsuite = gpu -skip-if = toolkit == 'android' #android(WebGL) -[webgl/test_texSubImage2D.html] -subsuite = gpu -skip-if = toolkit == 'android' #android(WebGL) -[webgl/test_uniformMatrixNfv.html] -subsuite = gpu -skip-if = toolkit == 'android' #android(WebGL) diff --git a/dom/imptests/html/typedarrays/test_constructors.html b/dom/imptests/html/typedarrays/test_constructors.html deleted file mode 100644 index 60e0dc8fe8d7..000000000000 --- a/dom/imptests/html/typedarrays/test_constructors.html +++ /dev/null @@ -1,48 +0,0 @@ - -Typed Array constructors - - - - - - -
- diff --git a/dom/imptests/html/webgl/common.js b/dom/imptests/html/webgl/common.js deleted file mode 100644 index 416c21ce9330..000000000000 --- a/dom/imptests/html/webgl/common.js +++ /dev/null @@ -1,13 +0,0 @@ -function getGl() { - var c = document.createElement("canvas"); - var gl = c.getContext("experimental-webgl"); - assert_true(!!gl, "Should be able to get a context."); - return gl; -} - -function shouldGenerateGLError(cx, glError, fn) { - test(function() { - fn(); - assert_equals(cx.getError(), glError); - }, "Calling " + fn + " should generate a " + glError + " error."); -} diff --git a/dom/imptests/html/webgl/test_bufferSubData.html b/dom/imptests/html/webgl/test_bufferSubData.html deleted file mode 100644 index a97df9062d6e..000000000000 --- a/dom/imptests/html/webgl/test_bufferSubData.html +++ /dev/null @@ -1,26 +0,0 @@ - -bufferSubData - - - - - - -
- diff --git a/dom/imptests/html/webgl/test_compressedTexImage2D.html b/dom/imptests/html/webgl/test_compressedTexImage2D.html deleted file mode 100644 index b0a031add0be..000000000000 --- a/dom/imptests/html/webgl/test_compressedTexImage2D.html +++ /dev/null @@ -1,30 +0,0 @@ - -compressedTexImage2D - - - - - - -
- diff --git a/dom/imptests/html/webgl/test_compressedTexSubImage2D.html b/dom/imptests/html/webgl/test_compressedTexSubImage2D.html deleted file mode 100644 index 539f9e17f8a8..000000000000 --- a/dom/imptests/html/webgl/test_compressedTexSubImage2D.html +++ /dev/null @@ -1,30 +0,0 @@ - -compressedTexSubImage2D - - - - - - -
- diff --git a/dom/imptests/html/webgl/test_texImage2D.html b/dom/imptests/html/webgl/test_texImage2D.html deleted file mode 100644 index 2f769160dfde..000000000000 --- a/dom/imptests/html/webgl/test_texImage2D.html +++ /dev/null @@ -1,20 +0,0 @@ - -texImage2D - - - - - - -
- diff --git a/dom/imptests/html/webgl/test_texSubImage2D.html b/dom/imptests/html/webgl/test_texSubImage2D.html deleted file mode 100644 index 294b30c7607e..000000000000 --- a/dom/imptests/html/webgl/test_texSubImage2D.html +++ /dev/null @@ -1,20 +0,0 @@ - -texSubImage2D - - - - - - -
- diff --git a/dom/imptests/html/webgl/test_uniformMatrixNfv.html b/dom/imptests/html/webgl/test_uniformMatrixNfv.html deleted file mode 100644 index f75cbcb99724..000000000000 --- a/dom/imptests/html/webgl/test_uniformMatrixNfv.html +++ /dev/null @@ -1,33 +0,0 @@ - -uniformMatrix*fv - - - - - - - - -
- - diff --git a/dom/imptests/idlharness.js b/dom/imptests/idlharness.js deleted file mode 100644 index dbf13aa0c984..000000000000 --- a/dom/imptests/idlharness.js +++ /dev/null @@ -1,1684 +0,0 @@ -/* -Distributed under both the W3C Test Suite License [1] and the W3C -3-clause BSD License [2]. To contribute to a W3C Test Suite, see the -policies and contribution forms [3]. - -[1] http://www.w3.org/Consortium/Legal/2008/04-testsuite-license -[2] http://www.w3.org/Consortium/Legal/2008/03-bsd-license -[3] http://www.w3.org/2004/10/27-testcases -*/ - -/* For user documentation see docs/idlharness.md */ - -/** - * Notes for people who want to edit this file (not just use it as a library): - * - * Most of the interesting stuff happens in the derived classes of IdlObject, - * especially IdlInterface. The entry point for all IdlObjects is .test(), - * which is called by IdlArray.test(). An IdlObject is conceptually just - * "thing we want to run tests on", and an IdlArray is an array of IdlObjects - * with some additional data thrown in. - * - * The object model is based on what WebIDLParser.js produces, which is in turn - * based on its pegjs grammar. If you want to figure out what properties an - * object will have from WebIDLParser.js, the best way is to look at the - * grammar: - * - * https://github.com/darobin/webidl.js/blob/master/lib/grammar.peg - * - * So for instance: - * - * // interface definition - * interface - * = extAttrs:extendedAttributeList? S? "interface" S name:identifier w herit:ifInheritance? w "{" w mem:ifMember* w "}" w ";" w - * { return { type: "interface", name: name, inheritance: herit, members: mem, extAttrs: extAttrs }; } - * - * This means that an "interface" object will have a .type property equal to - * the string "interface", a .name property equal to the identifier that the - * parser found, an .inheritance property equal to either null or the result of - * the "ifInheritance" production found elsewhere in the grammar, and so on. - * After each grammatical production is a JavaScript function in curly braces - * that gets called with suitable arguments and returns some JavaScript value. - * - * (Note that the version of WebIDLParser.js we use might sometimes be - * out-of-date or forked.) - * - * The members and methods of the classes defined by this file are all at least - * briefly documented, hopefully. - */ -(function(){ -"use strict"; -/// Helpers /// -function constValue (cnt) { - if (cnt.type === "null") return null; - if (cnt.type === "NaN") return NaN; - if (cnt.type === "Infinity") return cnt.negative ? -Infinity : Infinity; - return cnt.value; -} - -function minOverloadLength(overloads) { - if (!overloads.length) { - return 0; - } - - return overloads.map(function(attr) { - return attr.arguments ? attr.arguments.filter(function(arg) { - return !arg.optional && !arg.variadic; - }).length : 0; - }) - .reduce(function(m, n) { return Math.min(m, n); }); -} - -/// IdlArray /// -// Entry point -self.IdlArray = function() -//@{ -{ - /** - * A map from strings to the corresponding named IdlObject, such as - * IdlInterface or IdlException. These are the things that test() will run - * tests on. - */ - this.members = {}; - - /** - * A map from strings to arrays of strings. The keys are interface or - * exception names, and are expected to also exist as keys in this.members - * (otherwise they'll be ignored). This is populated by add_objects() -- - * see documentation at the start of the file. The actual tests will be - * run by calling this.members[name].test_object(obj) for each obj in - * this.objects[name]. obj is a string that will be eval'd to produce a - * JavaScript value, which is supposed to be an object implementing the - * given IdlObject (interface, exception, etc.). - */ - this.objects = {}; - - /** - * When adding multiple collections of IDLs one at a time, an earlier one - * might contain a partial interface or implements statement that depends - * on a later one. Save these up and handle them right before we run - * tests. - * - * .partials is simply an array of objects from WebIDLParser.js' - * "partialinterface" production. .implements maps strings to arrays of - * strings, such that - * - * A implements B; - * A implements C; - * D implements E; - * - * results in { A: ["B", "C"], D: ["E"] }. - */ - this.partials = []; - this["implements"] = {}; -}; - -//@} -IdlArray.prototype.add_idls = function(raw_idls) -//@{ -{ - /** Entry point. See documentation at beginning of file. */ - this.internal_add_idls(WebIDL2.parse(raw_idls)); -}; - -//@} -IdlArray.prototype.add_untested_idls = function(raw_idls) -//@{ -{ - /** Entry point. See documentation at beginning of file. */ - var parsed_idls = WebIDL2.parse(raw_idls); - for (var i = 0; i < parsed_idls.length; i++) - { - parsed_idls[i].untested = true; - if ("members" in parsed_idls[i]) - { - for (var j = 0; j < parsed_idls[i].members.length; j++) - { - parsed_idls[i].members[j].untested = true; - } - } - } - this.internal_add_idls(parsed_idls); -}; - -//@} -IdlArray.prototype.internal_add_idls = function(parsed_idls) -//@{ -{ - /** - * Internal helper called by add_idls() and add_untested_idls(). - * parsed_idls is an array of objects that come from WebIDLParser.js's - * "definitions" production. The add_untested_idls() entry point - * additionally sets an .untested property on each object (and its - * .members) so that they'll be skipped by test() -- they'll only be - * used for base interfaces of tested interfaces, return types, etc. - */ - parsed_idls.forEach(parsed_idl => { - if (parsed_idl.type == "interface" && parsed_idl.partial) - { - this.partials.push(parsed_idl); - return; - } - - if (parsed_idl.type == "implements") - { - if (!(parsed_idl.target in this["implements"])) - { - this["implements"][parsed_idl.target] = []; - } - this["implements"][parsed_idl.target].push(parsed_idl["implements"]); - return; - } - - parsed_idl.array = this; - if (parsed_idl.name in this.members) - { - throw "Duplicate identifier " + parsed_idl.name; - } - switch(parsed_idl.type) - { - case "interface": - this.members[parsed_idl.name] = - new IdlInterface(parsed_idl, /* is_callback = */ false); - break; - - case "dictionary": - // Nothing to test, but we need the dictionary info around for type - // checks - this.members[parsed_idl.name] = new IdlDictionary(parsed_idl); - break; - - case "typedef": - this.members[parsed_idl.name] = new IdlTypedef(parsed_idl); - break; - - case "callback": - // TODO - console.log("callback not yet supported"); - break; - - case "enum": - this.members[parsed_idl.name] = new IdlEnum(parsed_idl); - break; - - case "callback interface": - this.members[parsed_idl.name] = - new IdlInterface(parsed_idl, /* is_callback = */ true); - break; - - default: - throw parsed_idl.name + ": " + parsed_idl.type + " not yet supported"; - } - }); -}; - -//@} -IdlArray.prototype.add_objects = function(dict) -//@{ -{ - /** Entry point. See documentation at beginning of file. */ - for (var k in dict) - { - if (k in this.objects) - { - this.objects[k] = this.objects[k].concat(dict[k]); - } - else - { - this.objects[k] = dict[k]; - } - } -}; - -//@} -IdlArray.prototype.prevent_multiple_testing = function(name) -//@{ -{ - /** Entry point. See documentation at beginning of file. */ - this.members[name].prevent_multiple_testing = true; -}; - -//@} -IdlArray.prototype.recursively_get_implements = function(interface_name) -//@{ -{ - /** - * Helper function for test(). Returns an array of things that implement - * interface_name, so if the IDL contains - * - * A implements B; - * B implements C; - * B implements D; - * - * then recursively_get_implements("A") should return ["B", "C", "D"]. - */ - var ret = this["implements"][interface_name]; - if (ret === undefined) - { - return []; - } - for (var i = 0; i < this["implements"][interface_name].length; i++) - { - ret = ret.concat(this.recursively_get_implements(ret[i])); - if (ret.indexOf(ret[i]) != ret.lastIndexOf(ret[i])) - { - throw "Circular implements statements involving " + ret[i]; - } - } - return ret; -}; - -//@} -IdlArray.prototype.test = function() -//@{ -{ - /** Entry point. See documentation at beginning of file. */ - - // First merge in all the partial interfaces and implements statements we - // encountered. - this.partials.forEach(parsed_idl => { - if (!(parsed_idl.name in this.members) - || !(this.members[parsed_idl.name] instanceof IdlInterface)) - { - throw "Partial interface " + parsed_idl.name + " with no original interface"; - } - if (parsed_idl.extAttrs) - { - parsed_idl.extAttrs.forEach(extAttr => { - this.members[parsed_idl.name].extAttrs.push(extAttr); - }); - } - parsed_idl.members.forEach(member => { - this.members[parsed_idl.name].members.push(new IdlInterfaceMember(member)); - }); - }); - this.partials = []; - - for (var lhs in this["implements"]) - { - this.recursively_get_implements(lhs).forEach(rhs => { - var errStr = lhs + " implements " + rhs + ", but "; - if (!(lhs in this.members)) throw errStr + lhs + " is undefined."; - if (!(this.members[lhs] instanceof IdlInterface)) throw errStr + lhs + " is not an interface."; - if (!(rhs in this.members)) throw errStr + rhs + " is undefined."; - if (!(this.members[rhs] instanceof IdlInterface)) throw errStr + rhs + " is not an interface."; - this.members[rhs].members.forEach(member => { - this.members[lhs].members.push(new IdlInterfaceMember(member)); - }); - }); - } - this["implements"] = {}; - - // Now run test() on every member, and test_object() for every object. - for (var name in this.members) - { - this.members[name].test(); - if (name in this.objects) - { - this.objects[name].forEach(str => { - this.members[name].test_object(str); - }); - } - } -}; - -//@} -IdlArray.prototype.assert_type_is = function(value, type) -//@{ -{ - /** - * Helper function that tests that value is an instance of type according - * to the rules of WebIDL. value is any JavaScript value, and type is an - * object produced by WebIDLParser.js' "type" production. That production - * is fairly elaborate due to the complexity of WebIDL's types, so it's - * best to look at the grammar to figure out what properties it might have. - */ - if (type.idlType == "any") - { - // No assertions to make - return; - } - - if (type.nullable && value === null) - { - // This is fine - return; - } - - if (type.array) - { - // TODO: not supported yet - return; - } - - if (type.sequence) - { - assert_true(Array.isArray(value), "is not array"); - if (!value.length) - { - // Nothing we can do. - return; - } - this.assert_type_is(value[0], type.idlType.idlType); - return; - } - - type = type.idlType; - - switch(type) - { - case "void": - assert_equals(value, undefined); - return; - - case "boolean": - assert_equals(typeof value, "boolean"); - return; - - case "byte": - assert_equals(typeof value, "number"); - assert_equals(value, Math.floor(value), "not an integer"); - assert_true(-128 <= value && value <= 127, "byte " + value + " not in range [-128, 127]"); - return; - - case "octet": - assert_equals(typeof value, "number"); - assert_equals(value, Math.floor(value), "not an integer"); - assert_true(0 <= value && value <= 255, "octet " + value + " not in range [0, 255]"); - return; - - case "short": - assert_equals(typeof value, "number"); - assert_equals(value, Math.floor(value), "not an integer"); - assert_true(-32768 <= value && value <= 32767, "short " + value + " not in range [-32768, 32767]"); - return; - - case "unsigned short": - assert_equals(typeof value, "number"); - assert_equals(value, Math.floor(value), "not an integer"); - assert_true(0 <= value && value <= 65535, "unsigned short " + value + " not in range [0, 65535]"); - return; - - case "long": - assert_equals(typeof value, "number"); - assert_equals(value, Math.floor(value), "not an integer"); - assert_true(-2147483648 <= value && value <= 2147483647, "long " + value + " not in range [-2147483648, 2147483647]"); - return; - - case "unsigned long": - assert_equals(typeof value, "number"); - assert_equals(value, Math.floor(value), "not an integer"); - assert_true(0 <= value && value <= 4294967295, "unsigned long " + value + " not in range [0, 4294967295]"); - return; - - case "long long": - assert_equals(typeof value, "number"); - return; - - case "unsigned long long": - case "DOMTimeStamp": - assert_equals(typeof value, "number"); - assert_true(0 <= value, "unsigned long long is negative"); - return; - - case "float": - case "double": - case "DOMHighResTimeStamp": - case "unrestricted float": - case "unrestricted double": - // TODO: distinguish these cases - assert_equals(typeof value, "number"); - return; - - case "DOMString": - case "ByteString": - case "USVString": - // TODO: https://github.com/w3c/testharness.js/issues/92 - assert_equals(typeof value, "string"); - return; - - case "object": - assert_true(typeof value == "object" || typeof value == "function", "wrong type: not object or function"); - return; - } - - if (!(type in this.members)) - { - throw "Unrecognized type " + type; - } - - if (this.members[type] instanceof IdlInterface) - { - // We don't want to run the full - // IdlInterface.prototype.test_instance_of, because that could result - // in an infinite loop. TODO: This means we don't have tests for - // NoInterfaceObject interfaces, and we also can't test objects that - // come from another self. - assert_true(typeof value == "object" || typeof value == "function", "wrong type: not object or function"); - if (value instanceof Object - && !this.members[type].has_extended_attribute("NoInterfaceObject") - && type in self) - { - assert_true(value instanceof self[type], "not instanceof " + type); - } - } - else if (this.members[type] instanceof IdlEnum) - { - assert_equals(typeof value, "string"); - } - else if (this.members[type] instanceof IdlDictionary) - { - // TODO: Test when we actually have something to test this on - } - else if (this.members[type] instanceof IdlTypedef) - { - // TODO: Test when we actually have something to test this on - } - else - { - throw "Type " + type + " isn't an interface or dictionary"; - } -}; -//@} - -/// IdlObject /// -function IdlObject() {} -IdlObject.prototype.test = function() -//@{ -{ - /** - * By default, this does nothing, so no actual tests are run for IdlObjects - * that don't define any (e.g., IdlDictionary at the time of this writing). - */ -}; - -//@} -IdlObject.prototype.has_extended_attribute = function(name) -//@{ -{ - /** - * This is only meaningful for things that support extended attributes, - * such as interfaces, exceptions, and members. - */ - return this.extAttrs.some(function(o) - { - return o.name == name; - }); -}; - -//@} - -/// IdlDictionary /// -// Used for IdlArray.prototype.assert_type_is -function IdlDictionary(obj) -//@{ -{ - /** - * obj is an object produced by the WebIDLParser.js "dictionary" - * production. - */ - - /** Self-explanatory. */ - this.name = obj.name; - - /** An array of objects produced by the "dictionaryMember" production. */ - this.members = obj.members; - - /** - * The name (as a string) of the dictionary type we inherit from, or null - * if there is none. - */ - this.base = obj.inheritance; -} - -//@} -IdlDictionary.prototype = Object.create(IdlObject.prototype); - -/// IdlInterface /// -function IdlInterface(obj, is_callback) { - /** - * obj is an object produced by the WebIDLParser.js "exception" or - * "interface" production, as appropriate. - */ - - /** Self-explanatory. */ - this.name = obj.name; - - /** A back-reference to our IdlArray. */ - this.array = obj.array; - - /** - * An indicator of whether we should run tests on the (exception) interface - * object and (exception) interface prototype object. Tests on members are - * controlled by .untested on each member, not this. - */ - this.untested = obj.untested; - - /** An array of objects produced by the "ExtAttr" production. */ - this.extAttrs = obj.extAttrs; - - /** An array of IdlInterfaceMembers. */ - this.members = obj.members.map(function(m){return new IdlInterfaceMember(m); }); - if (this.has_extended_attribute("Unforgeable")) { - this.members - .filter(function(m) { return !m["static"] && (m.type == "attribute" || m.type == "operation"); }) - .forEach(function(m) { return m.isUnforgeable = true; }); - } - - /** - * The name (as a string) of the type we inherit from, or null if there is - * none. - */ - this.base = obj.inheritance; - - this._is_callback = is_callback; -} -IdlInterface.prototype = Object.create(IdlObject.prototype); -IdlInterface.prototype.is_callback = function() -//@{ -{ - return this._is_callback; -}; -//@} - -IdlInterface.prototype.has_constants = function() -//@{ -{ - return this.members.some(function(member) { - return member.type === "const"; - }); -}; -//@} - -IdlInterface.prototype.is_global = function() -//@{ -{ - return this.extAttrs.some(function(attribute) { - return attribute.name === "Global" || - attribute.name === "PrimaryGlobal"; - }); -}; -//@} - -IdlInterface.prototype.test = function() -//@{ -{ - if (this.has_extended_attribute("NoInterfaceObject")) - { - // No tests to do without an instance. TODO: We should still be able - // to run tests on the prototype object, if we obtain one through some - // other means. - return; - } - - if (!this.untested) - { - // First test things to do with the exception/interface object and - // exception/interface prototype object. - this.test_self(); - } - // Then test things to do with its members (constants, fields, attributes, - // operations, . . .). These are run even if .untested is true, because - // members might themselves be marked as .untested. This might happen to - // interfaces if the interface itself is untested but a partial interface - // that extends it is tested -- then the interface itself and its initial - // members will be marked as untested, but the members added by the partial - // interface are still tested. - this.test_members(); -}; -//@} - -IdlInterface.prototype.test_self = function() -//@{ -{ - test(() => { - // This function tests WebIDL as of 2015-01-13. - // TODO: Consider [Exposed]. - - // "For every interface that is exposed in a given ECMAScript global - // environment and: - // * is a callback interface that has constants declared on it, or - // * is a non-callback interface that is not declared with the - // [NoInterfaceObject] extended attribute, - // a corresponding property MUST exist on the ECMAScript global object. - // The name of the property is the identifier of the interface, and its - // value is an object called the interface object. - // The property has the attributes { [[Writable]]: true, - // [[Enumerable]]: false, [[Configurable]]: true }." - if (this.is_callback() && !this.has_constants()) { - return; - } - - // TODO: Should we test here that the property is actually writable - // etc., or trust getOwnPropertyDescriptor? - assert_own_property(self, this.name, - "self does not have own property " + format_value(this.name)); - var desc = Object.getOwnPropertyDescriptor(self, this.name); - assert_false("get" in desc, "self's property " + format_value(this.name) + " has getter"); - assert_false("set" in desc, "self's property " + format_value(this.name) + " has setter"); - assert_true(desc.writable, "self's property " + format_value(this.name) + " is not writable"); - assert_false(desc.enumerable, "self's property " + format_value(this.name) + " is enumerable"); - assert_true(desc.configurable, "self's property " + format_value(this.name) + " is not configurable"); - - if (this.is_callback()) { - // "The internal [[Prototype]] property of an interface object for - // a callback interface MUST be the Object.prototype object." - assert_equals(Object.getPrototypeOf(self[this.name]), Object.prototype, - "prototype of self's property " + format_value(this.name) + " is not Object.prototype"); - - return; - } - - // "The interface object for a given non-callback interface is a - // function object." - // "If an object is defined to be a function object, then it has - // characteristics as follows:" - - // Its [[Prototype]] internal property is otherwise specified (see - // below). - - // "* Its [[Get]] internal property is set as described in ECMA-262 - // section 9.1.8." - // Not much to test for this. - - // "* Its [[Construct]] internal property is set as described in - // ECMA-262 section 19.2.2.3." - // Tested below if no constructor is defined. TODO: test constructors - // if defined. - - // "* Its @@hasInstance property is set as described in ECMA-262 - // section 19.2.3.8, unless otherwise specified." - // TODO - - // ES6 (rev 30) 19.1.3.6: - // "Else, if O has a [[Call]] internal method, then let builtinTag be - // "Function"." - assert_class_string(self[this.name], "Function", "class string of " + this.name); - - // "The [[Prototype]] internal property of an interface object for a - // non-callback interface is determined as follows:" - var prototype = Object.getPrototypeOf(self[this.name]); - if (this.base) { - // "* If the interface inherits from some other interface, the - // value of [[Prototype]] is the interface object for that other - // interface." - var has_interface_object = - !this.array - .members[this.base] - .has_extended_attribute("NoInterfaceObject"); - if (has_interface_object) { - assert_own_property(self, this.base, - 'should inherit from ' + this.base + - ', but self has no such property'); - assert_equals(prototype, self[this.base], - 'prototype of ' + this.name + ' is not ' + - this.base); - } - } else { - // "If the interface doesn't inherit from any other interface, the - // value of [[Prototype]] is %FunctionPrototype% ([ECMA-262], - // section 6.1.7.4)." - assert_equals(prototype, Function.prototype, - "prototype of self's property " + format_value(this.name) + " is not Function.prototype"); - } - - if (!this.has_extended_attribute("Constructor")) { - // "The internal [[Call]] method of the interface object behaves as - // follows . . . - // - // "If I was not declared with a [Constructor] extended attribute, - // then throw a TypeError." - assert_throws(new TypeError(), () => { - self[this.name](); - }, "interface object didn't throw TypeError when called as a function"); - assert_throws(new TypeError(), () => { - new self[this.name](); - }, "interface object didn't throw TypeError when called as a constructor"); - } - }, this.name + " interface: existence and properties of interface object"); - - if (!this.is_callback()) { - test(() => { - // This function tests WebIDL as of 2014-10-25. - // https://heycam.github.io/webidl/#es-interface-call - - assert_own_property(self, this.name, - "self does not have own property " + format_value(this.name)); - - // "Interface objects for non-callback interfaces MUST have a - // property named “length” with attributes { [[Writable]]: false, - // [[Enumerable]]: false, [[Configurable]]: true } whose value is - // a Number." - assert_own_property(self[this.name], "length"); - var desc = Object.getOwnPropertyDescriptor(self[this.name], "length"); - assert_false("get" in desc, this.name + ".length has getter"); - assert_false("set" in desc, this.name + ".length has setter"); - assert_false(desc.writable, this.name + ".length is writable"); - assert_false(desc.enumerable, this.name + ".length is enumerable"); - assert_true(desc.configurable, this.name + ".length is not configurable"); - - var constructors = this.extAttrs - .filter(function(attr) { return attr.name == "Constructor"; }); - var expected_length = minOverloadLength(constructors); - assert_equals(self[this.name].length, expected_length, "wrong value for " + this.name + ".length"); - }, this.name + " interface object length"); - } - - // TODO: Test named constructors if I find any interfaces that have them. - - test(() => { - // This function tests WebIDL as of 2015-01-21. - // https://heycam.github.io/webidl/#interface-object - - if (this.is_callback() && !this.has_constants()) { - return; - } - - assert_own_property(self, this.name, - "self does not have own property " + format_value(this.name)); - - if (this.is_callback()) { - assert_false("prototype" in self[this.name], - this.name + ' should not have a "prototype" property'); - return; - } - - // "An interface object for a non-callback interface must have a - // property named “prototype” with attributes { [[Writable]]: false, - // [[Enumerable]]: false, [[Configurable]]: false } whose value is an - // object called the interface prototype object. This object has - // properties that correspond to the regular attributes and regular - // operations defined on the interface, and is described in more detail - // in section 4.5.4 below." - assert_own_property(self[this.name], "prototype", - 'interface "' + this.name + '" does not have own property "prototype"'); - var desc = Object.getOwnPropertyDescriptor(self[this.name], "prototype"); - assert_false("get" in desc, this.name + ".prototype has getter"); - assert_false("set" in desc, this.name + ".prototype has setter"); - assert_false(desc.writable, this.name + ".prototype is writable"); - assert_false(desc.enumerable, this.name + ".prototype is enumerable"); - assert_false(desc.configurable, this.name + ".prototype is configurable"); - - // Next, test that the [[Prototype]] of the interface prototype object - // is correct. (This is made somewhat difficult by the existence of - // [NoInterfaceObject].) - // TODO: Aryeh thinks there's at least other place in this file where - // we try to figure out if an interface prototype object is - // correct. Consolidate that code. - - // "The interface prototype object for a given interface A must have an - // internal [[Prototype]] property whose value is returned from the - // following steps: - // "If A is declared with the [Global] or [PrimaryGlobal] extended - // attribute, and A supports named properties, then return the named - // properties object for A, as defined in section 4.5.5 below. - // "Otherwise, if A is declared to inherit from another interface, then - // return the interface prototype object for the inherited interface. - // "Otherwise, if A is declared with the [ArrayClass] extended - // attribute, then return %ArrayPrototype% ([ECMA-262], section - // 6.1.7.4). - // "Otherwise, return %ObjectPrototype% ([ECMA-262], section 6.1.7.4). - // ([ECMA-262], section 15.2.4). - if (this.name === "Window") { - assert_class_string(Object.getPrototypeOf(self[this.name].prototype), - 'WindowProperties', - 'Class name for prototype of Window' + - '.prototype is not "WindowProperties"'); - } else { - var inherit_interface, inherit_interface_has_interface_object; - if (this.base) { - inherit_interface = this.base; - inherit_interface_has_interface_object = - !this.array - .members[inherit_interface] - .has_extended_attribute("NoInterfaceObject"); - } else if (this.has_extended_attribute('ArrayClass')) { - inherit_interface = 'Array'; - inherit_interface_has_interface_object = true; - } else { - inherit_interface = 'Object'; - inherit_interface_has_interface_object = true; - } - if (inherit_interface_has_interface_object) { - assert_own_property(self, inherit_interface, - 'should inherit from ' + inherit_interface + ', but self has no such property'); - assert_own_property(self[inherit_interface], 'prototype', - 'should inherit from ' + inherit_interface + ', but that object has no "prototype" property'); - assert_equals(Object.getPrototypeOf(self[this.name].prototype), - self[inherit_interface].prototype, - 'prototype of ' + this.name + '.prototype is not ' + inherit_interface + '.prototype'); - } else { - // We can't test that we get the correct object, because this is the - // only way to get our hands on it. We only test that its class - // string, at least, is correct. - assert_class_string(Object.getPrototypeOf(self[this.name].prototype), - inherit_interface + 'Prototype', - 'Class name for prototype of ' + this.name + - '.prototype is not "' + inherit_interface + 'Prototype"'); - } - } - - // "The class string of an interface prototype object is the - // concatenation of the interface’s identifier and the string - // “Prototype”." - assert_class_string(self[this.name].prototype, this.name + "Prototype", - "class string of " + this.name + ".prototype"); - // String() should end up calling {}.toString if nothing defines a - // stringifier. - if (!this.has_stringifier()) { - assert_equals(String(self[this.name].prototype), "[object " + this.name + "Prototype]", - "String(" + this.name + ".prototype)"); - } - }, this.name + " interface: existence and properties of interface prototype object"); - - test(() => { - if (this.is_callback() && !this.has_constants()) { - return; - } - - assert_own_property(self, this.name, - "self does not have own property " + format_value(this.name)); - - if (this.is_callback()) { - assert_false("prototype" in self[this.name], - this.name + ' should not have a "prototype" property'); - return; - } - - assert_own_property(self[this.name], "prototype", - 'interface "' + this.name + '" does not have own property "prototype"'); - - // "If the [NoInterfaceObject] extended attribute was not specified on - // the interface, then the interface prototype object must also have a - // property named “constructor” with attributes { [[Writable]]: true, - // [[Enumerable]]: false, [[Configurable]]: true } whose value is a - // reference to the interface object for the interface." - assert_own_property(self[this.name].prototype, "constructor", - this.name + '.prototype does not have own property "constructor"'); - var desc = Object.getOwnPropertyDescriptor(self[this.name].prototype, "constructor"); - assert_false("get" in desc, this.name + ".prototype.constructor has getter"); - assert_false("set" in desc, this.name + ".prototype.constructor has setter"); - assert_true(desc.writable, this.name + ".prototype.constructor is not writable"); - assert_false(desc.enumerable, this.name + ".prototype.constructor is enumerable"); - assert_true(desc.configurable, this.name + ".prototype.constructor in not configurable"); - assert_equals(self[this.name].prototype.constructor, self[this.name], - this.name + '.prototype.constructor is not the same object as ' + this.name); - }, this.name + ' interface: existence and properties of interface prototype object\'s "constructor" property'); -}; - -//@} -IdlInterface.prototype.test_member_const = function(member) -//@{ -{ - test(() => { - if (this.is_callback() && !this.has_constants()) { - return; - } - - assert_own_property(self, this.name, - "self does not have own property " + format_value(this.name)); - - // "For each constant defined on an interface A, there must be - // a corresponding property on the interface object, if it - // exists." - assert_own_property(self[this.name], member.name); - // "The value of the property is that which is obtained by - // converting the constant’s IDL value to an ECMAScript - // value." - assert_equals(self[this.name][member.name], constValue(member.value), - "property has wrong value"); - // "The property has attributes { [[Writable]]: false, - // [[Enumerable]]: true, [[Configurable]]: false }." - var desc = Object.getOwnPropertyDescriptor(self[this.name], member.name); - assert_false("get" in desc, "property has getter"); - assert_false("set" in desc, "property has setter"); - assert_false(desc.writable, "property is writable"); - assert_true(desc.enumerable, "property is not enumerable"); - assert_false(desc.configurable, "property is configurable"); - }, this.name + " interface: constant " + member.name + " on interface object"); - // "In addition, a property with the same characteristics must - // exist on the interface prototype object." - test(() => { - if (this.is_callback() && !this.has_constants()) { - return; - } - - assert_own_property(self, this.name, - "self does not have own property " + format_value(this.name)); - - if (this.is_callback()) { - assert_false("prototype" in self[this.name], - this.name + ' should not have a "prototype" property'); - return; - } - - assert_own_property(self[this.name], "prototype", - 'interface "' + this.name + '" does not have own property "prototype"'); - - assert_own_property(self[this.name].prototype, member.name); - assert_equals(self[this.name].prototype[member.name], constValue(member.value), - "property has wrong value"); - var desc = Object.getOwnPropertyDescriptor(self[this.name], member.name); - assert_false("get" in desc, "property has getter"); - assert_false("set" in desc, "property has setter"); - assert_false(desc.writable, "property is writable"); - assert_true(desc.enumerable, "property is not enumerable"); - assert_false(desc.configurable, "property is configurable"); - }, this.name + " interface: constant " + member.name + " on interface prototype object"); -}; - - -//@} -IdlInterface.prototype.test_member_attribute = function(member) -//@{ -{ - test(() => { - if (this.is_callback() && !this.has_constants()) { - return; - } - - assert_own_property(self, this.name, - "self does not have own property " + format_value(this.name)); - assert_own_property(self[this.name], "prototype", - 'interface "' + this.name + '" does not have own property "prototype"'); - - if (member["static"]) { - assert_own_property(self[this.name], member.name, - "The interface object must have a property " + - format_value(member.name)); - } else if (this.is_global()) { - assert_own_property(self, member.name, - "The global object must have a property " + - format_value(member.name)); - assert_false(member.name in self[this.name].prototype, - "The prototype object must not have a property " + - format_value(member.name)); - - // Try/catch around the get here, since it can legitimately throw. - // If it does, we obviously can't check for equality with direct - // invocation of the getter. - var gotValue; - var propVal; - try { - propVal = self[member.name]; - gotValue = true; - } catch (e) { - gotValue = false; - } - if (gotValue) { - var getter = Object.getOwnPropertyDescriptor(self, member.name).get; - assert_equals(typeof(getter), "function", - format_value(member.name) + " must have a getter"); - assert_equals(propVal, getter.call(undefined), - "Gets on a global should not require an explicit this"); - } - this.do_interface_attribute_asserts(self, member); - } else { - assert_true(member.name in self[this.name].prototype, - "The prototype object must have a property " + - format_value(member.name)); - - if (!member.has_extended_attribute("LenientThis")) { - assert_throws(new TypeError(), () => { - self[this.name].prototype[member.name]; - }, "getting property on prototype object must throw TypeError"); - } else { - assert_equals(self[this.name].prototype[member.name], undefined, - "getting property on prototype object must return undefined"); - } - this.do_interface_attribute_asserts(self[this.name].prototype, member); - } - }, this.name + " interface: attribute " + member.name); -}; - -//@} -IdlInterface.prototype.test_member_operation = function(member) -//@{ -{ - test(() => { - if (this.is_callback() && !this.has_constants()) { - return; - } - - assert_own_property(self, this.name, - "self does not have own property " + format_value(this.name)); - - if (this.is_callback()) { - assert_false("prototype" in self[this.name], - this.name + ' should not have a "prototype" property'); - return; - } - - assert_own_property(self[this.name], "prototype", - 'interface "' + this.name + '" does not have own property "prototype"'); - - // "For each unique identifier of an operation defined on the - // interface, there must be a corresponding property on the - // interface prototype object (if it is a regular operation) or - // the interface object (if it is a static operation), unless - // the effective overload set for that identifier and operation - // and with an argument count of 0 (for the ECMAScript language - // binding) has no entries." - // - var memberHolderObject; - if (member["static"]) { - assert_own_property(self[this.name], member.name, - "interface object missing static operation"); - memberHolderObject = self[this.name]; - } else if (this.is_global()) { - assert_own_property(self, member.name, - "global object missing non-static operation"); - memberHolderObject = self; - } else { - assert_own_property(self[this.name].prototype, member.name, - "interface prototype object missing non-static operation"); - memberHolderObject = self[this.name].prototype; - } - - this.do_member_operation_asserts(memberHolderObject, member); - }, this.name + " interface: operation " + member.name + - "(" + member.arguments.map(function(m) { return m.idlType.idlType; }) + - ")"); -}; - -//@} -IdlInterface.prototype.do_member_operation_asserts = function(memberHolderObject, member) -//@{ -{ - var operationUnforgeable = member.isUnforgeable; - var desc = Object.getOwnPropertyDescriptor(memberHolderObject, member.name); - // "The property has attributes { [[Writable]]: B, - // [[Enumerable]]: true, [[Configurable]]: B }, where B is false if the - // operation is unforgeable on the interface, and true otherwise". - assert_false("get" in desc, "property has getter"); - assert_false("set" in desc, "property has setter"); - assert_equals(desc.writable, !operationUnforgeable, - "property should be writable if and only if not unforgeable"); - assert_true(desc.enumerable, "property is not enumerable"); - assert_equals(desc.configurable, !operationUnforgeable, - "property should be configurable if and only if not unforgeable"); - // "The value of the property is a Function object whose - // behavior is as follows . . ." - assert_equals(typeof memberHolderObject[member.name], "function", - "property must be a function"); - // "The value of the Function object’s “length” property is - // a Number determined as follows: - // ". . . - // "Return the length of the shortest argument list of the - // entries in S." - assert_equals(memberHolderObject[member.name].length, - minOverloadLength(this.members.filter(function(m) { - return m.type == "operation" && m.name == member.name; - })), - "property has wrong .length"); - - // Make some suitable arguments - var args = member.arguments.map(function(arg) { - return create_suitable_object(arg.idlType); - }); - - // "Let O be a value determined as follows: - // ". . . - // "Otherwise, throw a TypeError." - // This should be hit if the operation is not static, there is - // no [ImplicitThis] attribute, and the this value is null. - // - // TODO: We currently ignore the [ImplicitThis] case. Except we manually - // check for globals, since otherwise we'll invoke window.close(). And we - // have to skip this test for anything that on the proto chain of "self", - // since that does in fact have implicit-this behavior. - if (!member["static"]) { - if (!this.is_global() && - memberHolderObject[member.name] != self[member.name]) - { - assert_throws(new TypeError(), function() { - memberHolderObject[member.name].apply(null, args); - }, "calling operation with this = null didn't throw TypeError"); - } - - // ". . . If O is not null and is also not a platform object - // that implements interface I, throw a TypeError." - // - // TODO: Test a platform object that implements some other - // interface. (Have to be sure to get inheritance right.) - assert_throws(new TypeError(), function() { - memberHolderObject[member.name].apply({}, args); - }, "calling operation with this = {} didn't throw TypeError"); - } -} - -//@} -IdlInterface.prototype.test_member_stringifier = function(member) -//@{ -{ - test(() => { - if (this.is_callback() && !this.has_constants()) { - return; - } - - assert_own_property(self, this.name, - "self does not have own property " + format_value(this.name)); - - if (this.is_callback()) { - assert_false("prototype" in self[this.name], - this.name + ' should not have a "prototype" property'); - return; - } - - assert_own_property(self[this.name], "prototype", - 'interface "' + this.name + '" does not have own property "prototype"'); - - // ". . . the property exists on the interface prototype object." - var interfacePrototypeObject = self[this.name].prototype; - assert_own_property(self[this.name].prototype, "toString", - "interface prototype object missing non-static operation"); - - var stringifierUnforgeable = member.isUnforgeable; - var desc = Object.getOwnPropertyDescriptor(interfacePrototypeObject, "toString"); - // "The property has attributes { [[Writable]]: B, - // [[Enumerable]]: true, [[Configurable]]: B }, where B is false if the - // stringifier is unforgeable on the interface, and true otherwise." - assert_false("get" in desc, "property has getter"); - assert_false("set" in desc, "property has setter"); - assert_equals(desc.writable, !stringifierUnforgeable, - "property should be writable if and only if not unforgeable"); - assert_true(desc.enumerable, "property is not enumerable"); - assert_equals(desc.configurable, !stringifierUnforgeable, - "property should be configurable if and only if not unforgeable"); - // "The value of the property is a Function object, which behaves as - // follows . . ." - assert_equals(typeof interfacePrototypeObject.toString, "function", - "property must be a function"); - // "The value of the Function object’s “length” property is the Number - // value 0." - assert_equals(interfacePrototypeObject.toString.length, 0, - "property has wrong .length"); - - // "Let O be the result of calling ToObject on the this value." - assert_throws(new TypeError(), function() { - self[this.name].prototype.toString.apply(null, []); - }, "calling stringifier with this = null didn't throw TypeError"); - - // "If O is not an object that implements the interface on which the - // stringifier was declared, then throw a TypeError." - // - // TODO: Test a platform object that implements some other - // interface. (Have to be sure to get inheritance right.) - assert_throws(new TypeError(), function() { - self[this.name].prototype.toString.apply({}, []); - }, "calling stringifier with this = {} didn't throw TypeError"); - }, this.name + " interface: stringifier"); -}; - -//@} -IdlInterface.prototype.test_members = function() -//@{ -{ - for (var i = 0; i < this.members.length; i++) - { - var member = this.members[i]; - if (member.untested) { - continue; - } - - switch (member.type) { - case "const": - this.test_member_const(member); - break; - - case "attribute": - // For unforgeable attributes, we do the checks in - // test_interface_of instead. - if (!member.isUnforgeable) - { - this.test_member_attribute(member); - } - break; - - case "operation": - // TODO: Need to correctly handle multiple operations with the same - // identifier. - // For unforgeable operations, we do the checks in - // test_interface_of instead. - if (member.name) { - if (!member.isUnforgeable) - { - this.test_member_operation(member); - } - } else if (member.stringifier) { - this.test_member_stringifier(member); - } - break; - - default: - // TODO: check more member types. - break; - } - } -}; - -//@} -IdlInterface.prototype.test_object = function(desc) -//@{ -{ - var obj, exception = null; - try - { - obj = eval(desc); - } - catch(e) - { - exception = e; - } - - // TODO: WebIDLParser doesn't currently support named legacycallers, so I'm - // not sure what those would look like in the AST - var expected_typeof = this.members.some(function(member) - { - return member.legacycaller - || ("idlType" in member && member.idlType.legacycaller) - || ("idlType" in member && typeof member.idlType == "object" - && "idlType" in member.idlType && member.idlType.idlType == "legacycaller"); - }) ? "function" : "object"; - - this.test_primary_interface_of(desc, obj, exception, expected_typeof); - var current_interface = this; - while (current_interface) - { - if (!(current_interface.name in this.array.members)) - { - throw "Interface " + current_interface.name + " not found (inherited by " + this.name + ")"; - } - if (current_interface.prevent_multiple_testing && current_interface.already_tested) - { - return; - } - current_interface.test_interface_of(desc, obj, exception, expected_typeof); - current_interface = this.array.members[current_interface.base]; - } -}; - -//@} -IdlInterface.prototype.test_primary_interface_of = function(desc, obj, exception, expected_typeof) -//@{ -{ - // We can't easily test that its prototype is correct if there's no - // interface object, or the object is from a different global environment - // (not instanceof Object). TODO: test in this case that its prototype at - // least looks correct, even if we can't test that it's actually correct. - if (!this.has_extended_attribute("NoInterfaceObject") - && (typeof obj != expected_typeof || obj instanceof Object)) - { - test(() => { - assert_equals(exception, null, "Unexpected exception when evaluating object"); - assert_equals(typeof obj, expected_typeof, "wrong typeof object"); - assert_own_property(self, this.name, - "self does not have own property " + format_value(this.name)); - assert_own_property(self[this.name], "prototype", - 'interface "' + this.name + '" does not have own property "prototype"'); - - // "The value of the internal [[Prototype]] property of the - // platform object is the interface prototype object of the primary - // interface from the platform object’s associated global - // environment." - assert_equals(Object.getPrototypeOf(obj), - self[this.name].prototype, - desc + "'s prototype is not " + this.name + ".prototype"); - }, this.name + " must be primary interface of " + desc); - } - - // "The class string of a platform object that implements one or more - // interfaces must be the identifier of the primary interface of the - // platform object." - test(() => { - assert_equals(exception, null, "Unexpected exception when evaluating object"); - assert_equals(typeof obj, expected_typeof, "wrong typeof object"); - assert_class_string(obj, this.name, "class string of " + desc); - if (!this.has_stringifier()) - { - assert_equals(String(obj), "[object " + this.name + "]", "String(" + desc + ")"); - } - }, "Stringification of " + desc); -}; - -//@} -IdlInterface.prototype.test_interface_of = function(desc, obj, exception, expected_typeof) -//@{ -{ - // TODO: Indexed and named properties, more checks on interface members - this.already_tested = true; - - for (var i = 0; i < this.members.length; i++) - { - var member = this.members[i]; - if (member.type == "attribute" && member.isUnforgeable) - { - test(() => { - assert_equals(exception, null, "Unexpected exception when evaluating object"); - assert_equals(typeof obj, expected_typeof, "wrong typeof object"); - this.do_interface_attribute_asserts(obj, member); - }, this.name + " interface: " + desc + ' must have own property "' + member.name + '"'); - } - else if (member.type == "operation" && - member.name && - member.isUnforgeable) - { - test(() => { - assert_equals(exception, null, "Unexpected exception when evaluating object"); - assert_equals(typeof obj, expected_typeof, "wrong typeof object"); - assert_own_property(obj, member.name, - "Doesn't have the unforgeable operation property"); - this.do_member_operation_asserts(obj, member); - }, this.name + " interface: " + desc + ' must have own property "' + member.name + '"'); - } - else if ((member.type == "const" - || member.type == "attribute" - || member.type == "operation") - && member.name) - { - test(() => { - assert_equals(exception, null, "Unexpected exception when evaluating object"); - assert_equals(typeof obj, expected_typeof, "wrong typeof object"); - if (!member["static"]) { - if (!this.is_global()) { - assert_inherits(obj, member.name); - } else { - assert_own_property(obj, member.name); - } - - if (member.type == "const") - { - assert_equals(obj[member.name], constValue(member.value)); - } - if (member.type == "attribute") - { - // Attributes are accessor properties, so they might - // legitimately throw an exception rather than returning - // anything. - var property, thrown = false; - try - { - property = obj[member.name]; - } - catch (e) - { - thrown = true; - } - if (!thrown) - { - this.array.assert_type_is(property, member.idlType); - } - } - if (member.type == "operation") - { - assert_equals(typeof obj[member.name], "function"); - } - } - }, this.name + " interface: " + desc + ' must inherit property "' + member.name + '" with the proper type (' + i + ')'); - } - // TODO: This is wrong if there are multiple operations with the same - // identifier. - // TODO: Test passing arguments of the wrong type. - if (member.type == "operation" && member.name && member.arguments.length) - { - test(() => { - assert_equals(exception, null, "Unexpected exception when evaluating object"); - assert_equals(typeof obj, expected_typeof, "wrong typeof object"); - if (!member["static"]) { - if (!this.is_global() && !member.isUnforgeable) { - assert_inherits(obj, member.name); - } else { - assert_own_property(obj, member.name); - } - } - else - { - assert_false(member.name in obj); - } - - var minLength = minOverloadLength(this.members.filter(function(m) { - return m.type == "operation" && m.name == member.name; - })); - var args = []; - for (var i = 0; i < minLength; i++) { - assert_throws(new TypeError(), () => { - obj[member.name].apply(obj, args); - }, "Called with " + i + " arguments"); - - args.push(create_suitable_object(member.arguments[i].idlType)); - } - }, this.name + " interface: calling " + member.name + - "(" + member.arguments.map(function(m) { return m.idlType.idlType; }) + - ") on " + desc + " with too few arguments must throw TypeError"); - } - } -}; - -//@} -IdlInterface.prototype.has_stringifier = function() -//@{ -{ - if (this.members.some(function(member) { return member.stringifier; })) { - return true; - } - if (this.base && - this.array.members[this.base].has_stringifier()) { - return true; - } - return false; -}; - -//@} -IdlInterface.prototype.do_interface_attribute_asserts = function(obj, member) -//@{ -{ - // This function tests WebIDL as of 2015-01-27. - // TODO: Consider [Exposed]. - - // This is called by test_member_attribute() with the prototype as obj if - // it is not a global, and the global otherwise, and by test_interface_of() - // with the object as obj. - - // "For each exposed attribute of the interface, whether it was declared on - // the interface itself or one of its consequential interfaces, there MUST - // exist a corresponding property. The characteristics of this property are - // as follows:" - - // "The name of the property is the identifier of the attribute." - assert_own_property(obj, member.name); - - // "The property has attributes { [[Get]]: G, [[Set]]: S, [[Enumerable]]: - // true, [[Configurable]]: configurable }, where: - // "configurable is false if the attribute was declared with the - // [Unforgeable] extended attribute and true otherwise; - // "G is the attribute getter, defined below; and - // "S is the attribute setter, also defined below." - var desc = Object.getOwnPropertyDescriptor(obj, member.name); - assert_false("value" in desc, 'property descriptor has value but is supposed to be accessor'); - assert_false("writable" in desc, 'property descriptor has "writable" field but is supposed to be accessor'); - assert_true(desc.enumerable, "property is not enumerable"); - if (member.isUnforgeable) - { - assert_false(desc.configurable, "[Unforgeable] property must not be configurable"); - } - else - { - assert_true(desc.configurable, "property must be configurable"); - } - - - // "The attribute getter is a Function object whose behavior when invoked - // is as follows:" - assert_equals(typeof desc.get, "function", "getter must be Function"); - - // "If the attribute is a regular attribute, then:" - if (!member["static"]) { - // "If O is not a platform object that implements I, then: - // "If the attribute was specified with the [LenientThis] extended - // attribute, then return undefined. - // "Otherwise, throw a TypeError." - if (!member.has_extended_attribute("LenientThis")) { - assert_throws(new TypeError(), () => { - desc.get.call({}); - }, "calling getter on wrong object type must throw TypeError"); - } else { - assert_equals(desc.get.call({}), undefined, - "calling getter on wrong object type must return undefined"); - } - } - - // "The value of the Function object’s “length” property is the Number - // value 0." - assert_equals(desc.get.length, 0, "getter length must be 0"); - - - // TODO: Test calling setter on the interface prototype (should throw - // TypeError in most cases). - if (member.readonly - && !member.has_extended_attribute("PutForwards") - && !member.has_extended_attribute("Replaceable")) - { - // "The attribute setter is undefined if the attribute is declared - // readonly and has neither a [PutForwards] nor a [Replaceable] - // extended attribute declared on it." - assert_equals(desc.set, undefined, "setter must be undefined for readonly attributes"); - } - else - { - // "Otherwise, it is a Function object whose behavior when - // invoked is as follows:" - assert_equals(typeof desc.set, "function", "setter must be function for PutForwards, Replaceable, or non-readonly attributes"); - - // "If the attribute is a regular attribute, then:" - if (!member["static"]) { - // "If /validThis/ is false and the attribute was not specified - // with the [LenientThis] extended attribute, then throw a - // TypeError." - // "If the attribute is declared with a [Replaceable] extended - // attribute, then: ..." - // "If validThis is false, then return." - if (!member.has_extended_attribute("LenientThis")) { - assert_throws(new TypeError(), () => { - desc.set.call({}); - }, "calling setter on wrong object type must throw TypeError"); - } else { - assert_equals(desc.set.call({}), undefined, - "calling setter on wrong object type must return undefined"); - } - } - - // "The value of the Function object’s “length” property is the Number - // value 1." - assert_equals(desc.set.length, 1, "setter length must be 1"); - } -} -//@} - -/// IdlInterfaceMember /// -function IdlInterfaceMember(obj) -//@{ -{ - /** - * obj is an object produced by the WebIDLParser.js "ifMember" production. - * We just forward all properties to this object without modification, - * except for special extAttrs handling. - */ - for (var k in obj) - { - this[k] = obj[k]; - } - if (!("extAttrs" in this)) - { - this.extAttrs = []; - } - - this.isUnforgeable = this.has_extended_attribute("Unforgeable"); -} - -//@} -IdlInterfaceMember.prototype = Object.create(IdlObject.prototype); - -/// Internal helper functions /// -function create_suitable_object(type) -//@{ -{ - /** - * type is an object produced by the WebIDLParser.js "type" production. We - * return a JavaScript value that matches the type, if we can figure out - * how. - */ - if (type.nullable) - { - return null; - } - switch (type.idlType) - { - case "any": - case "boolean": - return true; - - case "byte": case "octet": case "short": case "unsigned short": - case "long": case "unsigned long": case "long long": - case "unsigned long long": case "float": case "double": - case "unrestricted float": case "unrestricted double": - return 7; - - case "DOMString": - case "ByteString": - case "USVString": - return "foo"; - - case "object": - return {a: "b"}; - - case "Node": - return document.createTextNode("abc"); - } - return null; -} -//@} - -/// IdlEnum /// -// Used for IdlArray.prototype.assert_type_is -function IdlEnum(obj) -//@{ -{ - /** - * obj is an object produced by the WebIDLParser.js "dictionary" - * production. - */ - - /** Self-explanatory. */ - this.name = obj.name; - - /** An array of values produced by the "enum" production. */ - this.values = obj.values; - -} -//@} - -IdlEnum.prototype = Object.create(IdlObject.prototype); - -/// IdlTypedef /// -// Used for IdlArray.prototype.assert_type_is -function IdlTypedef(obj) -//@{ -{ - /** - * obj is an object produced by the WebIDLParser.js "typedef" - * production. - */ - - /** Self-explanatory. */ - this.name = obj.name; - - /** An array of values produced by the "typedef" production. */ - this.values = obj.values; - -} -//@} - -IdlTypedef.prototype = Object.create(IdlObject.prototype); - -}()); -// vim: set expandtab shiftwidth=4 tabstop=4 foldmarker=@{,@} foldmethod=marker: diff --git a/dom/imptests/importTestsuite.py b/dom/imptests/importTestsuite.py deleted file mode 100644 index c66b28fb3264..000000000000 --- a/dom/imptests/importTestsuite.py +++ /dev/null @@ -1,189 +0,0 @@ -#!/usr/bin/env python -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this file, -# You can obtain one at http://mozilla.org/MPL/2.0/. - -""" -Imports a test suite from a remote repository. Takes one argument, a file in -the format described in README. -Note: removes both source and destination directory before starting. Do not - use with outstanding changes in either directory. -""" - -from __future__ import print_function, unicode_literals - -import os -import shutil -import subprocess -import sys - -import parseManifest -import writeBuildFiles - -def readManifests(iden, dirs): - def parseManifestFile(iden, path): - pathstr = "hg-%s/%s/MANIFEST" % (iden, path) - subdirs, mochitests, reftests, _, supportfiles = parseManifest.parseManifestFile(pathstr) - return subdirs, mochitests, reftests, supportfiles - - data = [] - for path in dirs: - subdirs, mochitests, reftests, supportfiles = parseManifestFile(iden, path) - data.append({ - "path": path, - "mochitests": mochitests, - "reftests": reftests, - "supportfiles": supportfiles, - }) - data.extend(readManifests(iden, ["%s/%s" % (path, d) for d in subdirs])) - return data - - -def getData(confFile): - """This function parses a file of the form - (hg or git)|URL of remote repository|identifier for the local directory - First directory of tests - ... - Last directory of tests""" - vcs = "" - url = "" - iden = "" - directories = [] - try: - with open(confFile, 'r') as fp: - first = True - for line in fp: - if first: - vcs, url, iden = line.strip().split("|") - first = False - else: - directories.append(line.strip()) - finally: - return vcs, url, iden, directories - - -def makePathInternal(a, b): - if not b: - # Empty directory, i.e., the repository root. - return a - return "%s/%s" % (a, b) - - -def makeSourcePath(a, b): - """Make a path in the source (upstream) directory.""" - return makePathInternal("hg-%s" % a, b) - - -def makeDestPath(a, b): - """Make a path in the destination (mozilla-central) directory, shortening as - appropriate.""" - def shorten(path): - path = path.replace('dom-tree-accessors', 'dta') - path = path.replace('document.getElementsByName', 'doc.gEBN') - path = path.replace('requirements-for-implementations', 'implreq') - path = path.replace('other-elements-attributes-and-apis', 'oeaaa') - return path - - return shorten(makePathInternal(a, b)) - - -def extractReftestFiles(reftests): - """Returns the set of files referenced in the reftests argument""" - files = set() - for line in reftests: - files.update([line[1], line[2]]) - return files - - -def copy(dest, directories): - """Copy mochitests and support files from the external HG directory to their - place in mozilla-central. - """ - print("Copying tests...") - for d in directories: - sourcedir = makeSourcePath(dest, d["path"]) - destdir = makeDestPath(dest, d["path"]) - os.makedirs(destdir) - - reftestfiles = extractReftestFiles(d["reftests"]) - - for mochitest in d["mochitests"]: - shutil.copy("%s/%s" % (sourcedir, mochitest), "%s/test_%s" % (destdir, mochitest)) - for reftest in sorted(reftestfiles): - shutil.copy("%s/%s" % (sourcedir, reftest), "%s/%s" % (destdir, reftest)) - for support in d["supportfiles"]: - shutil.copy("%s/%s" % (sourcedir, support), "%s/%s" % (destdir, support)) - -def printBuildFiles(dest, directories): - """Create a mochitest.ini that all the contains tests we import. - """ - print("Creating manifest...") - all_mochitests = set() - all_support = set() - - for d in directories: - path = makeDestPath(dest, d["path"]) - - all_mochitests |= set('%s/test_%s' % (d['path'], mochitest) - for mochitest in d['mochitests']) - all_support |= set('%s/%s' % (d['path'], p) for p in d['supportfiles']) - - if d["reftests"]: - with open(path + "/reftest.list", "w") as fh: - result = writeBuildFiles.substReftestList("importTestsuite.py", - d["reftests"]) - fh.write(result) - - manifest_path = dest + '/mochitest.ini' - with open(manifest_path, 'w') as fh: - result = writeBuildFiles.substManifest('importTestsuite.py', - all_mochitests, all_support) - fh.write(result) - subprocess.check_call(["hg", "add", manifest_path]) - -def hgadd(dest, directories): - """Inform hg of the files in |directories|.""" - print("hg addremoving...") - for d in directories: - subprocess.check_call(["hg", "addremove", makeDestPath(dest, d)]) - -def removeAndCloneRepo(vcs, url, dest): - """Replaces the repo at dest by a fresh clone from url using vcs""" - assert vcs in ('hg', 'git') - - print("Removing %s..." % dest) - subprocess.check_call(["rm", "-rf", dest]) - - print("Cloning %s to %s with %s..." % (url, dest, vcs)) - subprocess.check_call([vcs, "clone", url, dest]) - -def importRepo(confFile): - try: - vcs, url, iden, directories = getData(confFile) - dest = iden - hgdest = "hg-%s" % iden - - print("Removing %s..." % dest) - subprocess.check_call(["rm", "-rf", dest]) - - removeAndCloneRepo(vcs, url, hgdest) - - data = readManifests(iden, directories) - print("Going to import %s..." % [d["path"] for d in data]) - - copy(dest, data) - printBuildFiles(dest, data) - hgadd(dest, directories) - print("Removing %s again..." % hgdest) - subprocess.check_call(["rm", "-rf", hgdest]) - except subprocess.CalledProcessError as e: - print(e.returncode) - finally: - print("Done") - -if __name__ == "__main__": - if len(sys.argv) != 2: - print("Need one argument.") - else: - importRepo(sys.argv[1]) - diff --git a/dom/imptests/moz.build b/dom/imptests/moz.build deleted file mode 100644 index 6f2a9ad290c1..000000000000 --- a/dom/imptests/moz.build +++ /dev/null @@ -1,37 +0,0 @@ -# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*- -# vim: set filetype=python: -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. - -with Files("**"): - BUG_COMPONENT = ("Core", "DOM: Core & HTML") - -with Files("html/webgl/**"): - BUG_COMPONENT = ("Core", "Canvas: 2D") - -with Files("html/typedarrays/**"): - BUG_COMPONENT = ("Core", "JavaScript: Standard Library") - -with Files("html/js/**"): - BUG_COMPONENT = ("Core", "JavaScript: Standard Library") - -with Files("html/html/**"): - BUG_COMPONENT = ("Core", "DOM: Core & HTML") - -MOCHITEST_MANIFESTS += [ - 'html/mochitest.ini', - 'webapps/mochitest.ini', -] - -MOCHITEST_MANIFESTS += [ - 'failures/html/typedarrays/mochitest.ini', -] - -TEST_HARNESS_FILES.testing.mochitest.resources += [ - 'idlharness.js', - 'testharness.css', - 'testharness.js', - 'testharnessreport.js', - 'WebIDLParser.js', -] diff --git a/dom/imptests/parseFailures.py b/dom/imptests/parseFailures.py deleted file mode 100644 index 6824b836c6d0..000000000000 --- a/dom/imptests/parseFailures.py +++ /dev/null @@ -1,79 +0,0 @@ -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this -# file, You can obtain one at http://mozilla.org/MPL/2.0/. - -from __future__ import print_function, unicode_literals - -import collections -import json -import os -import sys - -import writeBuildFiles - -def extractLines(fp): - lines = [] - watch = False - for line in fp: - line = line.decode('utf-8') - if line == '@@@ @@@ Failures\n': - watch = True - elif watch: - watch = False - idx = line.index('@@@') - lines.append((line[:idx], line[idx + 3:])) - return lines - -def ensuredir(path): - dir = path[:path.rfind('/')] - if not os.path.exists(dir): - os.makedirs(dir) - -def dumpFailures(lines): - files = [] - for url, objstr in lines: - if objstr == '{}\n': - continue - - # Avoid overly large diffs. - if 'editing/' in url: - sep = ':' - else: - sep = ': ' - - jsonpath = 'failures/' + url + '.json' - files.append(jsonpath) - ensuredir(jsonpath) - obj = json.loads(objstr, object_pairs_hook=collections.OrderedDict) - formattedobjstr = json.dumps(obj, indent=2, separators=(',', sep)) + '\n' - formattedobj = formattedobjstr.encode('utf-8') - fp = open(jsonpath, 'wb') - fp.write(formattedobj) - fp.close() - return files - -def writeFiles(files): - pathmap = {} - for path in files: - dirp, leaf = path.rsplit('/', 1) - pathmap.setdefault(dirp, []).append(leaf) - - for k, v in pathmap.items(): - with open(k + '/mochitest.ini', 'w') as fh: - result = writeBuildFiles.substManifest('parseFailures.py', v, []) - fh.write(result) - - -def main(logPath): - fp = open(logPath, 'rb') - lines = extractLines(fp) - fp.close() - - files = dumpFailures(lines) - writeFiles(files) - -if __name__ == '__main__': - if len(sys.argv) < 2: - print("Please pass the path to the logfile from which failures should be extracted.") - main(sys.argv[1]) - diff --git a/dom/imptests/parseManifest.py b/dom/imptests/parseManifest.py deleted file mode 100644 index 94412122d635..000000000000 --- a/dom/imptests/parseManifest.py +++ /dev/null @@ -1,69 +0,0 @@ -# Copyright (C) 2011-2013 Ms2ger -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. - - -def parseManifest(fd): - def parseReftestLine(chunks): - assert len(chunks) % 2 == 0 - reftests = [] - for i in range(2, len(chunks), 2): - if not chunks[i] in ["==", "!="]: - raise Exception("Misformatted reftest line " + line) - reftests.append([chunks[i], chunks[1], chunks[i + 1]]) - return reftests - - dirs = [] - autotests = [] - reftests = [] - othertests = [] - supportfiles = [] - for fullline in fd: - line = fullline.strip() - if not line: - continue - - chunks = line.split(" ") - - if chunks[0] == "MANIFEST": - raise Exception("MANIFEST listed on line " + line) - - if chunks[0] == "dir": - dirs.append(chunks[1]) - elif chunks[0] == "support" and chunks[1] == "dir": - dirs.append(chunks[1]) - elif chunks[0] == "ref": - if len(chunks) % 2: - raise Exception("Missing chunk in line " + line) - reftests.extend(parseReftestLine(chunks)) - elif chunks[0] == "support": - supportfiles.append(chunks[1]) - elif chunks[0] in ["manual", "parser", "http"]: - othertests.append(chunks[1]) - else: - # automated - autotests.append(chunks[0]) - return dirs, autotests, reftests, othertests, supportfiles - - -def parseManifestFile(path): - fp = open(path) - dirs, autotests, reftests, othertests, supportfiles = parseManifest(fp) - fp.close() - return dirs, autotests, reftests, othertests, supportfiles diff --git a/dom/imptests/updateTestharness.py b/dom/imptests/updateTestharness.py deleted file mode 100644 index 42deadcd4b32..000000000000 --- a/dom/imptests/updateTestharness.py +++ /dev/null @@ -1,25 +0,0 @@ -#!/usr/bin/env python -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this file, -# You can obtain one at http://mozilla.org/MPL/2.0/. - -from __future__ import unicode_literals - -import subprocess - -repo = "https://github.com/w3c/testharness.js" -dest = "resources-upstream" -files = [{"f":"testharness.js"}, - {"f":"testharness.css"}, - {"f":"idlharness.js"}, - {"d":"webidl2/lib/webidl2.js", "f":"WebIDLParser.js"}] - -subprocess.check_call(["git", "clone", repo, dest]) -subprocess.check_call(["git", "submodule", "init"], cwd=dest) -subprocess.check_call(["git", "submodule", "update"], cwd=dest) -for f in files: - path = f["d"] if "d" in f else f["f"] - subprocess.check_call(["cp", "%s/%s" % (dest, path), f["f"]]) - subprocess.check_call(["hg", "add", f["f"]]) -subprocess.check_call(["rm", "-rf", dest]) - diff --git a/dom/imptests/webapps.txt b/dom/imptests/webapps.txt deleted file mode 100644 index f6673d51a732..000000000000 --- a/dom/imptests/webapps.txt +++ /dev/null @@ -1,2 +0,0 @@ -hg|https://dvcs.w3.org/hg/webapps|webapps -XMLHttpRequest/tests/submissions/Ms2ger diff --git a/dom/imptests/webapps/XMLHttpRequest/tests/submissions/Ms2ger/test_FormData-append.html b/dom/imptests/webapps/XMLHttpRequest/tests/submissions/Ms2ger/test_FormData-append.html deleted file mode 100644 index b05c5169b54a..000000000000 --- a/dom/imptests/webapps/XMLHttpRequest/tests/submissions/Ms2ger/test_FormData-append.html +++ /dev/null @@ -1,14 +0,0 @@ - - -FormData.append - - - -
- diff --git a/dom/imptests/webapps/XMLHttpRequest/tests/submissions/Ms2ger/test_interfaces.html b/dom/imptests/webapps/XMLHttpRequest/tests/submissions/Ms2ger/test_interfaces.html deleted file mode 100644 index 165d013d29f4..000000000000 --- a/dom/imptests/webapps/XMLHttpRequest/tests/submissions/Ms2ger/test_interfaces.html +++ /dev/null @@ -1,102 +0,0 @@ - - -XMLHttpRequest IDL tests -
- - - - - - - diff --git a/dom/imptests/webapps/XMLHttpRequest/tests/submissions/Ms2ger/test_setrequestheader-invalid-arguments.htm b/dom/imptests/webapps/XMLHttpRequest/tests/submissions/Ms2ger/test_setrequestheader-invalid-arguments.htm deleted file mode 100644 index a077ad95f222..000000000000 --- a/dom/imptests/webapps/XMLHttpRequest/tests/submissions/Ms2ger/test_setrequestheader-invalid-arguments.htm +++ /dev/null @@ -1,42 +0,0 @@ - - - - XMLHttpRequest: setRequestHeader() with invalid arguments - - - - -
- - - - diff --git a/dom/imptests/webapps/mochitest.ini b/dom/imptests/webapps/mochitest.ini deleted file mode 100644 index bd971e436c66..000000000000 --- a/dom/imptests/webapps/mochitest.ini +++ /dev/null @@ -1,4 +0,0 @@ -# THIS FILE IS AUTOGENERATED BY importTestsuite.py - DO NOT EDIT -[XMLHttpRequest/tests/submissions/Ms2ger/test_FormData-append.html] -[XMLHttpRequest/tests/submissions/Ms2ger/test_interfaces.html] -[XMLHttpRequest/tests/submissions/Ms2ger/test_setrequestheader-invalid-arguments.htm] diff --git a/dom/imptests/writeBuildFiles.py b/dom/imptests/writeBuildFiles.py deleted file mode 100644 index 5a12add83836..000000000000 --- a/dom/imptests/writeBuildFiles.py +++ /dev/null @@ -1,43 +0,0 @@ -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this file, -# You can obtain one at http://mozilla.org/MPL/2.0/. - -from __future__ import unicode_literals - -import string - -manifest_template = """# THIS FILE IS AUTOGENERATED BY ${caller} - DO NOT EDIT -[DEFAULT] -support-files = -${supportfiles} - -${tests} -""" - -reftest_template = """# THIS FILE IS AUTOGENERATED BY ${caller} - DO NOT EDIT - -${reftests} -""" - - - -def substManifest(caller, test_files, support_files): - test_files = [f.lstrip('/') for f in test_files] - support_files = [f.lstrip('/') for f in support_files] - - return string.Template(manifest_template).substitute({ - 'caller': caller, - 'supportfiles': '\n'.join(' %s' % f for f in sorted(support_files)), - 'tests': '\n'.join('[%s]' % f for f in sorted(test_files)) - }) - - -def substReftestList(caller, tests): - def reftests(tests): - return "\n".join(" ".join(line) for line in tests) - - return string.Template(reftest_template).substitute({ - "caller": caller, - "reftests": reftests(tests), - }) - diff --git a/dom/moz.build b/dom/moz.build index a5c27386676a..b72d5e6fd2de 100644 --- a/dom/moz.build +++ b/dom/moz.build @@ -120,7 +120,6 @@ DIRS += ['presentation'] TEST_DIRS += [ 'tests', - 'imptests', ] if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('gtk', 'cocoa', 'windows'): diff --git a/python/mozbuild/TODO b/python/mozbuild/TODO deleted file mode 100644 index 4f519f9dd791..000000000000 --- a/python/mozbuild/TODO +++ /dev/null @@ -1,3 +0,0 @@ -dom/imptests Makefile.in's are autogenerated. See -dom/imptests/writeMakefile.py and bug 782651. We will need to update -writeMakefile.py to produce mozbuild files. diff --git a/testing/mochitest/runtests.py b/testing/mochitest/runtests.py index 11b4be28c8e4..9b104b05ab1e 100644 --- a/testing/mochitest/runtests.py +++ b/testing/mochitest/runtests.py @@ -1437,17 +1437,7 @@ toolbar#nav-bar { info = mozinfo.info - # Bug 1089034 - imptest failure expectations are encoded as - # test manifests, even though they aren't tests. This gross - # hack causes several problems in automation including - # throwing off the chunking numbers. Remove them manually - # until bug 1089034 is fixed. - def remove_imptest_failure_expectations(tests, values): - return (t for t in tests - if 'imptests/failures' not in t['path']) - filters = [ - remove_imptest_failure_expectations, subsuite(options.subsuite), ]