From b509ca5ec9d029cd1e447e0c77d236f57fa2c50f Mon Sep 17 00:00:00 2001 From: James Graham Date: Mon, 18 Aug 2014 15:33:06 +0100 Subject: [PATCH] Fix tests that have duplicate names. --- ambient-light/DeviceLightEvent_tests.js | 2 +- cors/origin.htm | 5 + .../Document-getElementsByTagNameNS.html | 4 +- dom/nodes/selectors.js | 120 ++--- dom/ranges/Range-selectNode.html | 118 ++--- domxpath/001.html | 2 +- html/dom/reflection.js | 8 +- .../input-textselection-01.html | 2 +- html/webappapis/atob/base64.html | 446 +++++++++--------- ...s.html => DeviceProximityEvent_tests.html} | 2 +- proximity/UserProximityEvent_tests.html | 10 + proximity/UserProximityEvent_tests.js | 2 +- .../tests/submissions/Opera/level2-lib.js | 6 +- 13 files changed, 373 insertions(+), 354 deletions(-) rename proximity/{ProximityEvent_tests.html => DeviceProximityEvent_tests.html} (87%) create mode 100644 proximity/UserProximityEvent_tests.html diff --git a/ambient-light/DeviceLightEvent_tests.js b/ambient-light/DeviceLightEvent_tests.js index b91281f1b6c416..af89cb45c3f715 100644 --- a/ambient-light/DeviceLightEvent_tests.js +++ b/ambient-light/DeviceLightEvent_tests.js @@ -391,7 +391,7 @@ t.done(); }); - var t2 = async_test('test if DeviceLightEvent received'); + var t2 = async_test('test if DeviceLightEvent received (event handler attribute)'); window.ondevicelight = function(e) { t2.step(function() { var msg = 'expected instance of DeviceLightEvent: '; diff --git a/cors/origin.htm b/cors/origin.htm index a090b3340fc7ef..a9ccef4cdda71d 100644 --- a/cors/origin.htm +++ b/cors/origin.htm @@ -40,7 +40,12 @@

Access-Control-Allow-Origin handling

shouldPass(" "+location.protocol + "//" + location.host); +var failOrigins = []; function shouldFail(origin) { + if (failOrigins.indexOf(origin) > -1) { + return; + } + failOrigins.push(origin); test(function () { var client = new XMLHttpRequest() client.open('GET', CROSSDOMAIN diff --git a/dom/nodes/Document-getElementsByTagNameNS.html b/dom/nodes/Document-getElementsByTagNameNS.html index 0f97d03021dc1c..1c6d85d2d909cb 100644 --- a/dom/nodes/Document-getElementsByTagNameNS.html +++ b/dom/nodes/Document-getElementsByTagNameNS.html @@ -60,7 +60,7 @@ this.add_cleanup(function() {document.body.removeChild(t)}) assert_array_equals(document.getElementsByTagNameNS("test", "BODY"), [t]); assert_array_equals(document.getElementsByTagNameNS("test", "body"), []); -}, "body element in test namespace, no prefix") +}, "BODY element in test namespace, no prefix") test(function() { var t = document.body.appendChild(document.createElementNS("http://www.w3.org/1999/xhtml", "abc")) @@ -90,7 +90,7 @@ this.add_cleanup(function() {document.body.removeChild(t)}) assert_array_equals(document.getElementsByTagNameNS("test", "BODY"), [t]); assert_array_equals(document.getElementsByTagNameNS("test", "body"), []); -}, "body element in test namespace, prefix") +}, "BODY element in test namespace, prefix") test(function() { var t = document.body.appendChild(document.createElementNS("test", "test:test")) diff --git a/dom/nodes/selectors.js b/dom/nodes/selectors.js index 3710587953ac99..e0d68bd98a6846 100644 --- a/dom/nodes/selectors.js +++ b/dom/nodes/selectors.js @@ -587,26 +587,26 @@ var scopedSelectors = [ // XXX Fix ctx in tests below // - :lang() - {name: ":lang pseudo-class selector, matching inherited language", selector: "#pseudo-lang-div1:lang(en)", ctx: "", expect: ["pseudo-lang-div1"], exclude: ["detached", "fragment"], level: 2, testType: TEST_FIND | TEST_MATCH}, + {name: ":lang pseudo-class selector, matching inherited language (1)", selector: "#pseudo-lang-div1:lang(en)", ctx: "", expect: ["pseudo-lang-div1"], exclude: ["detached", "fragment"], level: 2, testType: TEST_FIND | TEST_MATCH}, {name: ":lang pseudo-class selector, not matching element with no inherited language", selector: "#pseudo-lang-div1:lang(en)", ctx: "", expect: [] /*no matches*/, exclude: ["document", "element"], level: 2, testType: TEST_FIND}, - {name: ":lang pseudo-class selector, matching specified language with exact value", selector: "#pseudo-lang-div2:lang(fr)", ctx: "", expect: ["pseudo-lang-div2"], level: 2, testType: TEST_FIND | TEST_MATCH}, - {name: ":lang pseudo-class selector, matching specified language with partial value", selector: "#pseudo-lang-div3:lang(en)", ctx: "", expect: ["pseudo-lang-div3"], level: 2, testType: TEST_FIND | TEST_MATCH}, + {name: ":lang pseudo-class selector, matching specified language with exact value (1)", selector: "#pseudo-lang-div2:lang(fr)", ctx: "", expect: ["pseudo-lang-div2"], level: 2, testType: TEST_FIND | TEST_MATCH}, + {name: ":lang pseudo-class selector, matching specified language with partial value (1)", selector: "#pseudo-lang-div3:lang(en)", ctx: "", expect: ["pseudo-lang-div3"], level: 2, testType: TEST_FIND | TEST_MATCH}, {name: ":lang pseudo-class selector, not matching incorrect language", selector: "#pseudo-lang-div4:lang(es-AR)", ctx: "", expect: [] /*no matches*/, level: 2, testType: TEST_FIND}, // - :enabled (Level 3) - {name: ":enabled pseudo-class selector, matching all enabled form controls", selector: "#pseudo-ui :enabled", ctx: "", expect: ["pseudo-ui-input1", "pseudo-ui-input2", "pseudo-ui-input3", "pseudo-ui-input4", "pseudo-ui-input5", "pseudo-ui-input6", + {name: ":enabled pseudo-class selector, matching all enabled form controls (1)", selector: "#pseudo-ui :enabled", ctx: "", expect: ["pseudo-ui-input1", "pseudo-ui-input2", "pseudo-ui-input3", "pseudo-ui-input4", "pseudo-ui-input5", "pseudo-ui-input6", "pseudo-ui-input7", "pseudo-ui-input8", "pseudo-ui-input9", "pseudo-ui-textarea1", "pseudo-ui-button1"], level: 3, testType: TEST_FIND | TEST_MATCH}, // - :disabled (Level 3) - {name: ":enabled pseudo-class selector, matching all disabled form controls", selector: "#pseudo-ui :disabled", ctx: "", expect: ["pseudo-ui-input10", "pseudo-ui-input11", "pseudo-ui-input12", "pseudo-ui-input13", "pseudo-ui-input14", "pseudo-ui-input15", + {name: ":enabled pseudo-class selector, matching all disabled form controls (1)", selector: "#pseudo-ui :disabled", ctx: "", expect: ["pseudo-ui-input10", "pseudo-ui-input11", "pseudo-ui-input12", "pseudo-ui-input13", "pseudo-ui-input14", "pseudo-ui-input15", "pseudo-ui-input16", "pseudo-ui-input17", "pseudo-ui-input18", "pseudo-ui-textarea2", "pseudo-ui-button2"], level: 3, testType: TEST_FIND | TEST_MATCH}, // - :checked (Level 3) - {name: ":checked pseudo-class selector, matching checked radio buttons and checkboxes", selector: "#pseudo-ui :checked", ctx: "", expect: ["pseudo-ui-input4", "pseudo-ui-input6", "pseudo-ui-input13", "pseudo-ui-input15"], level: 3, testType: TEST_FIND | TEST_MATCH}, + {name: ":checked pseudo-class selector, matching checked radio buttons and checkboxes (1)", selector: "#pseudo-ui :checked", ctx: "", expect: ["pseudo-ui-input4", "pseudo-ui-input6", "pseudo-ui-input13", "pseudo-ui-input15"], level: 3, testType: TEST_FIND | TEST_MATCH}, // - :not(s) (Level 3) - {name: ":not pseudo-class selector, matching ", selector: "#not>:not(div)", ctx: "", expect: ["not-p1", "not-p2", "not-p3"], level: 3, testType: TEST_FIND | TEST_MATCH}, - {name: ":not pseudo-class selector, matching ", selector: "#not * :not(:first-child)", ctx: "", expect: ["not-em1", "not-em2", "not-em3"], level: 3, testType: TEST_FIND | TEST_MATCH}, + {name: ":not pseudo-class selector, matching (1)", selector: "#not>:not(div)", ctx: "", expect: ["not-p1", "not-p2", "not-p3"], level: 3, testType: TEST_FIND | TEST_MATCH}, + {name: ":not pseudo-class selector, matching (1)", selector: "#not * :not(:first-child)", ctx: "", expect: ["not-em1", "not-em2", "not-em3"], level: 3, testType: TEST_FIND | TEST_MATCH}, {name: ":not pseudo-class selector, matching nothing", selector: ":not(*)", ctx: "", expect: [] /* no matches */, level: 3, testType: TEST_FIND}, {name: ":not pseudo-class selector, matching nothing", selector: ":not(*|*)", ctx: "", expect: [] /* no matches */, level: 3, testType: TEST_FIND}, @@ -628,28 +628,28 @@ var scopedSelectors = [ {name: "::after pseudo-element (two-colon syntax) selector, not matching any elements", selector: "#pseudo-element::after", ctx: "", expect: [] /*no matches*/, level: 3, testType: TEST_FIND}, // Class Selectors - {name: "Class selector, matching element with specified class", selector: ".class-p", ctx: "", expect: ["class-p1","class-p2", "class-p3"], level: 1, testType: TEST_FIND | TEST_MATCH}, - {name: "Class selector, chained, matching only elements with all specified classes", selector: "#class .apple.orange.banana", ctx: "", expect: ["class-div1", "class-div2", "class-p4", "class-div3", "class-p6", "class-div4"], level: 1, testType: TEST_FIND | TEST_MATCH}, - {name: "Class Selector, chained, with type selector", selector: "div.apple.banana.orange", ctx: "", expect: ["class-div1", "class-div2", "class-div3", "class-div4"], level: 1, testType: TEST_FIND | TEST_MATCH}, + {name: "Class selector, matching element with specified class (1)", selector: ".class-p", ctx: "", expect: ["class-p1","class-p2", "class-p3"], level: 1, testType: TEST_FIND | TEST_MATCH}, + {name: "Class selector, chained, matching only elements with all specified classes (1)", selector: "#class .apple.orange.banana", ctx: "", expect: ["class-div1", "class-div2", "class-p4", "class-div3", "class-p6", "class-div4"], level: 1, testType: TEST_FIND | TEST_MATCH}, + {name: "Class Selector, chained, with type selector (1)", selector: "div.apple.banana.orange", ctx: "", expect: ["class-div1", "class-div2", "class-div3", "class-div4"], level: 1, testType: TEST_FIND | TEST_MATCH}, // Caution: If copying and pasting the folowing non-ASCII classes, ensure unicode normalisation is not performed in the process. {name: "Class selector, matching element with class value using non-ASCII characters", selector: ".台北Táiběi", ctx: "", expect: ["class-span1"], level: 1, testType: TEST_FIND | TEST_MATCH}, - {name: "Class selector, matching multiple elements with class value using non-ASCII characters", selector: ".台北", ctx: "", expect: ["class-span1","class-span2"], level: 1, testType: TEST_FIND | TEST_MATCH}, + {name: "Class selector, matching multiple elements with class value using non-ASCII characters (1)", selector: ".台北", ctx: "", expect: ["class-span1","class-span2"], level: 1, testType: TEST_FIND | TEST_MATCH}, {name: "Class selector, chained, matching element with multiple class values using non-ASCII characters", selector: ".台北Táiběi.台北", ctx: "", expect: ["class-span1"], level: 1, testType: TEST_FIND | TEST_MATCH}, - {name: "Class selector, matching element with class with escaped character", selector: ".foo\\:bar", ctx: "", expect: ["class-span3"], level: 1, testType: TEST_FIND | TEST_MATCH}, - {name: "Class selector, matching element with class with escaped character", selector: ".test\\.foo\\[5\\]bar", ctx: "", expect: ["class-span4"], level: 1, testType: TEST_FIND | TEST_MATCH}, + {name: "Class selector, matching element with class with escaped character (1)", selector: ".foo\\:bar", ctx: "", expect: ["class-span3"], level: 1, testType: TEST_FIND | TEST_MATCH}, + {name: "Class selector, matching element with class with escaped character (1)", selector: ".test\\.foo\\[5\\]bar", ctx: "", expect: ["class-span4"], level: 1, testType: TEST_FIND | TEST_MATCH}, // ID Selectors - {name: "ID selector, matching element with specified id", selector: "#id #id-div1", ctx: "", expect: ["id-div1"], level: 1, testType: TEST_FIND | TEST_MATCH}, - {name: "ID selector, chained, matching element with specified id", selector: "#id-div1, #id-div1", ctx: "", expect: ["id-div1"], level: 1, testType: TEST_FIND | TEST_MATCH}, - {name: "ID selector, chained, matching element with specified id", selector: "#id-div1, #id-div2", ctx: "", expect: ["id-div1", "id-div2"], level: 1, testType: TEST_FIND | TEST_MATCH}, - {name: "ID Selector, chained, with type selector", selector: "div#id-div1, div#id-div2", ctx: "", expect: ["id-div1", "id-div2"], level: 1, testType: TEST_FIND | TEST_MATCH}, + {name: "ID selector, matching element with specified id (1)", selector: "#id #id-div1", ctx: "", expect: ["id-div1"], level: 1, testType: TEST_FIND | TEST_MATCH}, + {name: "ID selector, chained, matching element with specified id (1)", selector: "#id-div1, #id-div1", ctx: "", expect: ["id-div1"], level: 1, testType: TEST_FIND | TEST_MATCH}, + {name: "ID selector, chained, matching element with specified id (1)", selector: "#id-div1, #id-div2", ctx: "", expect: ["id-div1", "id-div2"], level: 1, testType: TEST_FIND | TEST_MATCH}, + {name: "ID Selector, chained, with type selector (1)", selector: "div#id-div1, div#id-div2", ctx: "", expect: ["id-div1", "id-div2"], level: 1, testType: TEST_FIND | TEST_MATCH}, {name: "ID selector, not matching non-existent descendant", selector: "#id #none", ctx: "", expect: [] /*no matches*/, level: 1, testType: TEST_FIND}, {name: "ID selector, not matching non-existent ancestor", selector: "#none #id-div1", ctx: "", expect: [] /*no matches*/, level: 1, testType: TEST_FIND}, - {name: "ID selector, matching multiple elements with duplicate id", selector: "#id-li-duplicate", ctx: "", expect: ["id-li-duplicate", "id-li-duplicate", "id-li-duplicate", "id-li-duplicate"], level: 1, testType: TEST_FIND | TEST_MATCH}, + {name: "ID selector, matching multiple elements with duplicate id (1)", selector: "#id-li-duplicate", ctx: "", expect: ["id-li-duplicate", "id-li-duplicate", "id-li-duplicate", "id-li-duplicate"], level: 1, testType: TEST_FIND | TEST_MATCH}, // Caution: If copying and pasting the folowing non-ASCII IDs, ensure unicode normalisation is not performed in the process. {name: "ID selector, matching id value using non-ASCII characters", selector: "#台北Táiběi", ctx: "", expect: ["台北Táiběi"], level: 1, testType: TEST_FIND | TEST_MATCH}, - {name: "ID selector, matching id value using non-ASCII characters", selector: "#台北", ctx: "", expect: ["台北"], level: 1, testType: TEST_FIND | TEST_MATCH}, + {name: "ID selector, matching id value using non-ASCII characters (1)", selector: "#台北", ctx: "", expect: ["台北"], level: 1, testType: TEST_FIND | TEST_MATCH}, {name: "ID selector, matching id values using non-ASCII characters", selector: "#台北Táiběi, #台北", ctx: "", expect: ["台北Táiběi", "台北"], level: 1, testType: TEST_FIND | TEST_MATCH}, // XXX runMatchesTest() in level2-lib.js can't handle this because obtaining the expected nodes requires escaping characters when generating the selector from 'expect' values @@ -664,58 +664,58 @@ var scopedSelectors = [ // Combinators // - Descendant combinator ' ' - {name: "Descendant combinator, matching element that is a descendant of an element with id", selector: "#descendant div", ctx: "", expect: ["descendant-div1", "descendant-div2", "descendant-div3", "descendant-div4"], level: 1, testType: TEST_FIND | TEST_MATCH}, - {name: "Descendant combinator, matching element with id that is a descendant of an element", selector: "body #descendant-div1", ctx: "", expect: ["descendant-div1"], exclude: ["detached", "fragment"], level: 1, testType: TEST_FIND | TEST_MATCH}, - {name: "Descendant combinator, matching element with id that is a descendant of an element", selector: "div #descendant-div1", ctx: "", expect: ["descendant-div1"], level: 1, testType: TEST_FIND | TEST_MATCH}, - {name: "Descendant combinator, matching element with id that is a descendant of an element with id", selector: "#descendant #descendant-div2", ctx: "", expect: ["descendant-div2"], level: 1, testType: TEST_FIND | TEST_MATCH}, - {name: "Descendant combinator, matching element with class that is a descendant of an element with id", selector: "#descendant .descendant-div2", ctx: "", expect: ["descendant-div2"], level: 1, testType: TEST_FIND | TEST_MATCH}, - {name: "Descendant combinator, matching element with class that is a descendant of an element with class", selector: ".descendant-div1 .descendant-div3", ctx: "", expect: ["descendant-div3"], level: 1, testType: TEST_FIND | TEST_MATCH}, + {name: "Descendant combinator, matching element that is a descendant of an element with id (1)", selector: "#descendant div", ctx: "", expect: ["descendant-div1", "descendant-div2", "descendant-div3", "descendant-div4"], level: 1, testType: TEST_FIND | TEST_MATCH}, + {name: "Descendant combinator, matching element with id that is a descendant of an element (1)", selector: "body #descendant-div1", ctx: "", expect: ["descendant-div1"], exclude: ["detached", "fragment"], level: 1, testType: TEST_FIND | TEST_MATCH}, + {name: "Descendant combinator, matching element with id that is a descendant of an element (1)", selector: "div #descendant-div1", ctx: "", expect: ["descendant-div1"], level: 1, testType: TEST_FIND | TEST_MATCH}, + {name: "Descendant combinator, matching element with id that is a descendant of an element with id (1)", selector: "#descendant #descendant-div2", ctx: "", expect: ["descendant-div2"], level: 1, testType: TEST_FIND | TEST_MATCH}, + {name: "Descendant combinator, matching element with class that is a descendant of an element with id (1)", selector: "#descendant .descendant-div2", ctx: "", expect: ["descendant-div2"], level: 1, testType: TEST_FIND | TEST_MATCH}, + {name: "Descendant combinator, matching element with class that is a descendant of an element with class (1)", selector: ".descendant-div1 .descendant-div3", ctx: "", expect: ["descendant-div3"], level: 1, testType: TEST_FIND | TEST_MATCH}, {name: "Descendant combinator, not matching element with id that is not a descendant of an element with id", selector: "#descendant-div1 #descendant-div4", ctx: "", expect: [] /*no matches*/, level: 1, testType: TEST_FIND}, - {name: "Descendant combinator, whitespace characters", selector: "#descendant\t\r\n#descendant-div2", ctx: "", expect: ["descendant-div2"], level: 1, testType: TEST_FIND | TEST_MATCH}, + {name: "Descendant combinator, whitespace characters (1)", selector: "#descendant\t\r\n#descendant-div2", ctx: "", expect: ["descendant-div2"], level: 1, testType: TEST_FIND | TEST_MATCH}, // - Child combinator '>' - {name: "Child combinator, matching element that is a child of an element with id", selector: "#child>div", ctx: "", expect: ["child-div1", "child-div4"], level: 2, testType: TEST_FIND | TEST_MATCH}, - {name: "Child combinator, matching element with id that is a child of an element", selector: "div>#child-div1", ctx: "", expect: ["child-div1"], level: 2, testType: TEST_FIND | TEST_MATCH}, - {name: "Child combinator, matching element with id that is a child of an element with id", selector: "#child>#child-div1", ctx: "", expect: ["child-div1"], level: 2, testType: TEST_FIND | TEST_MATCH}, - {name: "Child combinator, matching element with id that is a child of an element with class", selector: "#child-div1>.child-div2", ctx: "", expect: ["child-div2"], level: 2, testType: TEST_FIND | TEST_MATCH}, - {name: "Child combinator, matching element with class that is a child of an element with class", selector: ".child-div1>.child-div2", ctx: "", expect: ["child-div2"], level: 2, testType: TEST_FIND | TEST_MATCH}, + {name: "Child combinator, matching element that is a child of an element with id (1)", selector: "#child>div", ctx: "", expect: ["child-div1", "child-div4"], level: 2, testType: TEST_FIND | TEST_MATCH}, + {name: "Child combinator, matching element with id that is a child of an element (1)", selector: "div>#child-div1", ctx: "", expect: ["child-div1"], level: 2, testType: TEST_FIND | TEST_MATCH}, + {name: "Child combinator, matching element with id that is a child of an element with id (1)", selector: "#child>#child-div1", ctx: "", expect: ["child-div1"], level: 2, testType: TEST_FIND | TEST_MATCH}, + {name: "Child combinator, matching element with id that is a child of an element with class (1)", selector: "#child-div1>.child-div2", ctx: "", expect: ["child-div2"], level: 2, testType: TEST_FIND | TEST_MATCH}, + {name: "Child combinator, matching element with class that is a child of an element with class (1)", selector: ".child-div1>.child-div2", ctx: "", expect: ["child-div2"], level: 2, testType: TEST_FIND | TEST_MATCH}, {name: "Child combinator, not matching element with id that is not a child of an element with id", selector: "#child>#child-div3", ctx: "", expect: [] /*no matches*/, level: 2, testType: TEST_FIND}, {name: "Child combinator, not matching element with id that is not a child of an element with class", selector: "#child-div1>.child-div3", ctx: "", expect: [] /*no matches*/, level: 2, testType: TEST_FIND}, {name: "Child combinator, not matching element with class that is not a child of an element with class", selector: ".child-div1>.child-div3", ctx: "", expect: [] /*no matches*/, level: 2, testType: TEST_FIND}, - {name: "Child combinator, surrounded by whitespace", selector: "#child-div1\t\r\n>\t\r\n#child-div2", ctx: "", expect: ["child-div2"], level: 2, testType: TEST_FIND | TEST_MATCH}, - {name: "Child combinator, whitespace after", selector: "#child-div1>\t\r\n#child-div2", ctx: "", expect: ["child-div2"], level: 2, testType: TEST_FIND | TEST_MATCH}, - {name: "Child combinator, whitespace before", selector: "#child-div1\t\r\n>#child-div2", ctx: "", expect: ["child-div2"], level: 2, testType: TEST_FIND | TEST_MATCH}, - {name: "Child combinator, no whitespace", selector: "#child-div1>#child-div2", ctx: "", expect: ["child-div2"], level: 2, testType: TEST_FIND | TEST_MATCH}, + {name: "Child combinator, surrounded by whitespace (1)", selector: "#child-div1\t\r\n>\t\r\n#child-div2", ctx: "", expect: ["child-div2"], level: 2, testType: TEST_FIND | TEST_MATCH}, + {name: "Child combinator, whitespace after (1)", selector: "#child-div1>\t\r\n#child-div2", ctx: "", expect: ["child-div2"], level: 2, testType: TEST_FIND | TEST_MATCH}, + {name: "Child combinator, whitespace before (1)", selector: "#child-div1\t\r\n>#child-div2", ctx: "", expect: ["child-div2"], level: 2, testType: TEST_FIND | TEST_MATCH}, + {name: "Child combinator, no whitespace (1)", selector: "#child-div1>#child-div2", ctx: "", expect: ["child-div2"], level: 2, testType: TEST_FIND | TEST_MATCH}, // - Adjacent sibling combinator '+' - {name: "Adjacent sibling combinator, matching element that is an adjacent sibling of an element with id", selector: "#adjacent-div2+div", ctx: "", expect: ["adjacent-div4"], level: 2, testType: TEST_FIND | TEST_MATCH}, - {name: "Adjacent sibling combinator, matching element with id that is an adjacent sibling of an element", selector: "div+#adjacent-div4", ctx: "", expect: ["adjacent-div4"], level: 2, testType: TEST_FIND | TEST_MATCH}, - {name: "Adjacent sibling combinator, matching element with id that is an adjacent sibling of an element with id", selector: "#adjacent-div2+#adjacent-div4", ctx: "", expect: ["adjacent-div4"], level: 2, testType: TEST_FIND | TEST_MATCH}, - {name: "Adjacent sibling combinator, matching element with class that is an adjacent sibling of an element with id", selector: "#adjacent-div2+.adjacent-div4", ctx: "", expect: ["adjacent-div4"], level: 2, testType: TEST_FIND | TEST_MATCH}, - {name: "Adjacent sibling combinator, matching element with class that is an adjacent sibling of an element with class", selector: ".adjacent-div2+.adjacent-div4", ctx: "", expect: ["adjacent-div4"], level: 2, testType: TEST_FIND | TEST_MATCH}, - {name: "Adjacent sibling combinator, matching p element that is an adjacent sibling of a div element", selector: "#adjacent div+p", ctx: "", expect: ["adjacent-p2"], level: 2, testType: TEST_FIND | TEST_MATCH}, + {name: "Adjacent sibling combinator, matching element that is an adjacent sibling of an element with id (1)", selector: "#adjacent-div2+div", ctx: "", expect: ["adjacent-div4"], level: 2, testType: TEST_FIND | TEST_MATCH}, + {name: "Adjacent sibling combinator, matching element with id that is an adjacent sibling of an element (1)", selector: "div+#adjacent-div4", ctx: "", expect: ["adjacent-div4"], level: 2, testType: TEST_FIND | TEST_MATCH}, + {name: "Adjacent sibling combinator, matching element with id that is an adjacent sibling of an element with id (1)", selector: "#adjacent-div2+#adjacent-div4", ctx: "", expect: ["adjacent-div4"], level: 2, testType: TEST_FIND | TEST_MATCH}, + {name: "Adjacent sibling combinator, matching element with class that is an adjacent sibling of an element with id (1)", selector: "#adjacent-div2+.adjacent-div4", ctx: "", expect: ["adjacent-div4"], level: 2, testType: TEST_FIND | TEST_MATCH}, + {name: "Adjacent sibling combinator, matching element with class that is an adjacent sibling of an element with class (1)", selector: ".adjacent-div2+.adjacent-div4", ctx: "", expect: ["adjacent-div4"], level: 2, testType: TEST_FIND | TEST_MATCH}, + {name: "Adjacent sibling combinator, matching p element that is an adjacent sibling of a div element (1)", selector: "#adjacent div+p", ctx: "", expect: ["adjacent-p2"], level: 2, testType: TEST_FIND | TEST_MATCH}, {name: "Adjacent sibling combinator, not matching element with id that is not an adjacent sibling of an element with id", selector: "#adjacent-div2+#adjacent-p2, #adjacent-div2+#adjacent-div1", ctx: "", expect: [] /*no matches*/, level: 2, testType: TEST_FIND}, - {name: "Adjacent sibling combinator, surrounded by whitespace", selector: "#adjacent-p2\t\r\n+\t\r\n#adjacent-p3", ctx: "", expect: ["adjacent-p3"], level: 2, testType: TEST_FIND | TEST_MATCH}, - {name: "Adjacent sibling combinator, whitespace after", selector: "#adjacent-p2+\t\r\n#adjacent-p3", ctx: "", expect: ["adjacent-p3"], level: 2, testType: TEST_FIND | TEST_MATCH}, - {name: "Adjacent sibling combinator, whitespace before", selector: "#adjacent-p2\t\r\n+#adjacent-p3", ctx: "", expect: ["adjacent-p3"], level: 2, testType: TEST_FIND | TEST_MATCH}, - {name: "Adjacent sibling combinator, no whitespace", selector: "#adjacent-p2+#adjacent-p3", ctx: "", expect: ["adjacent-p3"], level: 2, testType: TEST_FIND | TEST_MATCH}, + {name: "Adjacent sibling combinator, surrounded by whitespace (1)", selector: "#adjacent-p2\t\r\n+\t\r\n#adjacent-p3", ctx: "", expect: ["adjacent-p3"], level: 2, testType: TEST_FIND | TEST_MATCH}, + {name: "Adjacent sibling combinator, whitespace after (1)", selector: "#adjacent-p2+\t\r\n#adjacent-p3", ctx: "", expect: ["adjacent-p3"], level: 2, testType: TEST_FIND | TEST_MATCH}, + {name: "Adjacent sibling combinator, whitespace before (1)", selector: "#adjacent-p2\t\r\n+#adjacent-p3", ctx: "", expect: ["adjacent-p3"], level: 2, testType: TEST_FIND | TEST_MATCH}, + {name: "Adjacent sibling combinator, no whitespace (1)", selector: "#adjacent-p2+#adjacent-p3", ctx: "", expect: ["adjacent-p3"], level: 2, testType: TEST_FIND | TEST_MATCH}, // - General sibling combinator ~ (Level 3) - {name: "General sibling combinator, matching element that is a sibling of an element with id", selector: "#sibling-div2~div", ctx: "", expect: ["sibling-div4", "sibling-div6"], level: 3, testType: TEST_FIND | TEST_MATCH}, - {name: "General sibling combinator, matching element with id that is a sibling of an element", selector: "div~#sibling-div4", ctx: "", expect: ["sibling-div4"], level: 3, testType: TEST_FIND | TEST_MATCH}, - {name: "General sibling combinator, matching element with id that is a sibling of an element with id", selector: "#sibling-div2~#sibling-div4", ctx: "", expect: ["sibling-div4"], level: 3, testType: TEST_FIND | TEST_MATCH}, - {name: "General sibling combinator, matching element with class that is a sibling of an element with id", selector: "#sibling-div2~.sibling-div", ctx: "", expect: ["sibling-div4", "sibling-div6"], level: 3, testType: TEST_FIND | TEST_MATCH}, - {name: "General sibling combinator, matching p element that is a sibling of a div element", selector: "#sibling div~p", ctx: "", expect: ["sibling-p2", "sibling-p3"], level: 3, testType: TEST_FIND | TEST_MATCH}, - {name: "General sibling combinator, not matching element with id that is not a sibling after a p element", selector: "#sibling>p~div", ctx: "", expect: [] /*no matches*/, level: 3, testType: TEST_FIND}, + {name: "General sibling combinator, matching element that is a sibling of an element with id (1)", selector: "#sibling-div2~div", ctx: "", expect: ["sibling-div4", "sibling-div6"], level: 3, testType: TEST_FIND | TEST_MATCH}, + {name: "General sibling combinator, matching element with id that is a sibling of an element (1)", selector: "div~#sibling-div4", ctx: "", expect: ["sibling-div4"], level: 3, testType: TEST_FIND | TEST_MATCH}, + {name: "General sibling combinator, matching element with id that is a sibling of an element with id (1)", selector: "#sibling-div2~#sibling-div4", ctx: "", expect: ["sibling-div4"], level: 3, testType: TEST_FIND | TEST_MATCH}, + {name: "General sibling combinator, matching element with class that is a sibling of an element with id (1)", selector: "#sibling-div2~.sibling-div", ctx: "", expect: ["sibling-div4", "sibling-div6"], level: 3, testType: TEST_FIND | TEST_MATCH}, + {name: "General sibling combinator, matching p element that is a sibling of a div element (1)", selector: "#sibling div~p", ctx: "", expect: ["sibling-p2", "sibling-p3"], level: 3, testType: TEST_FIND | TEST_MATCH}, + {name: "General sibling combinator, not matching element with id that is not a sibling after a p element (1)", selector: "#sibling>p~div", ctx: "", expect: [] /*no matches*/, level: 3, testType: TEST_FIND}, {name: "General sibling combinator, not matching element with id that is not a sibling after an element with id", selector: "#sibling-div2~#sibling-div3, #sibling-div2~#sibling-div1", ctx: "", expect: [] /*no matches*/, level: 3, testType: TEST_FIND}, - {name: "General sibling combinator, surrounded by whitespace", selector: "#sibling-p2\t\r\n~\t\r\n#sibling-p3", ctx: "", expect: ["sibling-p3"], level: 3, testType: TEST_FIND | TEST_MATCH}, - {name: "General sibling combinator, whitespace after", selector: "#sibling-p2~\t\r\n#sibling-p3", ctx: "", expect: ["sibling-p3"], level: 3, testType: TEST_FIND | TEST_MATCH}, - {name: "General sibling combinator, whitespace before", selector: "#sibling-p2\t\r\n~#sibling-p3", ctx: "", expect: ["sibling-p3"], level: 3, testType: TEST_FIND | TEST_MATCH}, - {name: "General sibling combinator, no whitespace", selector: "#sibling-p2~#sibling-p3", ctx: "", expect: ["sibling-p3"], level: 3, testType: TEST_FIND | TEST_MATCH}, + {name: "General sibling combinator, surrounded by whitespace (1)", selector: "#sibling-p2\t\r\n~\t\r\n#sibling-p3", ctx: "", expect: ["sibling-p3"], level: 3, testType: TEST_FIND | TEST_MATCH}, + {name: "General sibling combinator, whitespace after (1)", selector: "#sibling-p2~\t\r\n#sibling-p3", ctx: "", expect: ["sibling-p3"], level: 3, testType: TEST_FIND | TEST_MATCH}, + {name: "General sibling combinator, whitespace before (1)", selector: "#sibling-p2\t\r\n~#sibling-p3", ctx: "", expect: ["sibling-p3"], level: 3, testType: TEST_FIND | TEST_MATCH}, + {name: "General sibling combinator, no whitespace (1)", selector: "#sibling-p2~#sibling-p3", ctx: "", expect: ["sibling-p3"], level: 3, testType: TEST_FIND | TEST_MATCH}, // Group of selectors (comma) - {name: "Syntax, group of selectors separator, surrounded by whitespace", selector: "#group em\t\r \n,\t\r \n#group strong", ctx: "", expect: ["group-em1", "group-strong1"], level: 1, testType: TEST_FIND | TEST_MATCH}, - {name: "Syntax, group of selectors separator, whitespace after", selector: "#group em,\t\r\n#group strong", ctx: "", expect: ["group-em1", "group-strong1"], level: 1, testType: TEST_FIND | TEST_MATCH}, - {name: "Syntax, group of selectors separator, whitespace before", selector: "#group em\t\r\n,#group strong", ctx: "", expect: ["group-em1", "group-strong1"], level: 1, testType: TEST_FIND | TEST_MATCH}, - {name: "Syntax, group of selectors separator, no whitespace", selector: "#group em,#group strong", ctx: "", expect: ["group-em1", "group-strong1"], level: 1, testType: TEST_FIND | TEST_MATCH}, + {name: "Syntax, group of selectors separator, surrounded by whitespace (1)", selector: "#group em\t\r \n,\t\r \n#group strong", ctx: "", expect: ["group-em1", "group-strong1"], level: 1, testType: TEST_FIND | TEST_MATCH}, + {name: "Syntax, group of selectors separator, whitespace after (1)", selector: "#group em,\t\r\n#group strong", ctx: "", expect: ["group-em1", "group-strong1"], level: 1, testType: TEST_FIND | TEST_MATCH}, + {name: "Syntax, group of selectors separator, whitespace before (1)", selector: "#group em\t\r\n,#group strong", ctx: "", expect: ["group-em1", "group-strong1"], level: 1, testType: TEST_FIND | TEST_MATCH}, + {name: "Syntax, group of selectors separator, no whitespace (1)", selector: "#group em,#group strong", ctx: "", expect: ["group-em1", "group-strong1"], level: 1, testType: TEST_FIND | TEST_MATCH}, ]; diff --git a/dom/ranges/Range-selectNode.html b/dom/ranges/Range-selectNode.html index aee6f6f65c3476..2d9ec6b9a78238 100644 --- a/dom/ranges/Range-selectNode.html +++ b/dom/ranges/Range-selectNode.html @@ -10,56 +10,56 @@ "use strict"; function testSelectNode(range, node) { - try { - range.collapsed; - } catch (e) { - // Range is detached - assert_throws("INVALID_STATE_ERR", function () { - range.selectNode(node); - }, "selectNode() on a detached node must throw INVALID_STATE_ERR"); - assert_throws("INVALID_STATE_ERR", function () { - range.selectNodeContents(node); - }, "selectNodeContents() on a detached node must throw INVALID_STATE_ERR"); - return; - } + try { + range.collapsed; + } catch (e) { + // Range is detached + assert_throws("INVALID_STATE_ERR", function () { + range.selectNode(node); + }, "selectNode() on a detached node must throw INVALID_STATE_ERR"); + assert_throws("INVALID_STATE_ERR", function () { + range.selectNodeContents(node); + }, "selectNodeContents() on a detached node must throw INVALID_STATE_ERR"); + return; + } - if (!node.parentNode) { - assert_throws("INVALID_NODE_TYPE_ERR", function() { - range.selectNode(node); - }, "selectNode() on a node with no parent must throw INVALID_NODE_TYPE_ERR"); - } else { - var index = 0; - while (node.parentNode.childNodes[index] != node) { - index++; - } + if (!node.parentNode) { + assert_throws("INVALID_NODE_TYPE_ERR", function() { + range.selectNode(node); + }, "selectNode() on a node with no parent must throw INVALID_NODE_TYPE_ERR"); + } else { + var index = 0; + while (node.parentNode.childNodes[index] != node) { + index++; + } - range.selectNode(node); - assert_equals(range.startContainer, node.parentNode, - "After selectNode(), startContainer must equal parent node"); - assert_equals(range.endContainer, node.parentNode, - "After selectNode(), endContainer must equal parent node"); - assert_equals(range.startOffset, index, - "After selectNode(), startOffset must be index of node in parent (" + index + ")"); - assert_equals(range.endOffset, index + 1, - "After selectNode(), endOffset must be one plus index of node in parent (" + (index + 1) + ")"); - } + range.selectNode(node); + assert_equals(range.startContainer, node.parentNode, + "After selectNode(), startContainer must equal parent node"); + assert_equals(range.endContainer, node.parentNode, + "After selectNode(), endContainer must equal parent node"); + assert_equals(range.startOffset, index, + "After selectNode(), startOffset must be index of node in parent (" + index + ")"); + assert_equals(range.endOffset, index + 1, + "After selectNode(), endOffset must be one plus index of node in parent (" + (index + 1) + ")"); + } - if (node.nodeType == Node.DOCUMENT_TYPE_NODE) { - assert_throws("INVALID_NODE_TYPE_ERR", function () { - range.selectNodeContents(node); - }, "selectNodeContents() on a doctype must throw INVALID_NODE_TYPE_ERR"); - } else { - range.selectNodeContents(node); - assert_equals(range.startContainer, node, - "After selectNodeContents(), startContainer must equal node"); - assert_equals(range.endContainer, node, - "After selectNodeContents(), endContainer must equal node"); - assert_equals(range.startOffset, 0, - "After selectNodeContents(), startOffset must equal 0"); - var len = nodeLength(node); - assert_equals(range.endOffset, len, - "After selectNodeContents(), endOffset must equal node length (" + len + ")"); - } + if (node.nodeType == Node.DOCUMENT_TYPE_NODE) { + assert_throws("INVALID_NODE_TYPE_ERR", function () { + range.selectNodeContents(node); + }, "selectNodeContents() on a doctype must throw INVALID_NODE_TYPE_ERR"); + } else { + range.selectNodeContents(node); + assert_equals(range.startContainer, node, + "After selectNodeContents(), startContainer must equal node"); + assert_equals(range.endContainer, node, + "After selectNodeContents(), endContainer must equal node"); + assert_equals(range.startOffset, 0, + "After selectNodeContents(), startOffset must equal 0"); + var len = nodeLength(node); + assert_equals(range.endOffset, len, + "After selectNodeContents(), endOffset must equal node length (" + len + ")"); + } } var range = document.createRange(); @@ -69,17 +69,17 @@ detachedRange.detach(); var tests = []; function testTree(root, marker) { - if (root.nodeType == Node.ELEMENT_NODE && root.id == "log") { - // This is being modified during the tests, so let's not test it. - return; - } - tests.push([marker + root.nodeName.toLowerCase() + " node, current doc's range, type " + root.nodeType, range, root]); - tests.push([marker + root.nodeName.toLowerCase() + " node, foreign doc's range, type " + root.nodeType, foreignRange, root]); - tests.push([marker + root.nodeName.toLowerCase() + " node, XML doc's range, type " + root.nodeType, xmlRange, root]); - tests.push([marker + root.nodeName.toLowerCase() + " node, detached range, type " + root.nodeType, detachedRange, root]); - for (var i = 0; i < root.childNodes.length; i++) { - testTree(root.childNodes[i], "**" + marker); - } + if (root.nodeType == Node.ELEMENT_NODE && root.id == "log") { + // This is being modified during the tests, so let's not test it. + return; + } + tests.push([marker + root.nodeName.toLowerCase() + " node, current doc's range, type " + root.nodeType, range, root]); + tests.push([marker + root.nodeName.toLowerCase() + " node, foreign doc's range, type " + root.nodeType, foreignRange, root]); + tests.push([marker + root.nodeName.toLowerCase() + " node, XML doc's range, type " + root.nodeType, xmlRange, root]); + tests.push([marker + root.nodeName.toLowerCase() + " node, detached range, type " + root.nodeType, detachedRange, root]); + for (var i = 0; i < root.childNodes.length; i++) { + testTree(root.childNodes[i], "**" + marker); + } } testTree(document, " current doc: "); testTree(foreignDoc, " foreign doc: "); @@ -90,7 +90,7 @@ docfrag, foreignDocfrag, xmlDocfrag]; for (var i = 0; i < otherTests.length; i++) { - testTree(otherTests[i], " "); + testTree(otherTests[i], " "); } generate_tests(testSelectNode, tests); diff --git a/domxpath/001.html b/domxpath/001.html index 618435bd27f67a..c26795a3115f8b 100644 --- a/domxpath/001.html +++ b/domxpath/001.html @@ -51,7 +51,7 @@ ["SVG elements mixed case selector", "//svg:PatH", [], ns_resolver], ["Non-ascii HTML element", "//dØdd", document.getElementsByTagName("dØdd"), ns_resolver], ["Non-ascii HTML element2", "//dødd", [], ns_resolver], - ["Non-ascii HTML element2", "//DØDD", document.getElementsByTagName("dØdd"), ns_resolver] + ["Non-ascii HTML element3", "//DØDD", document.getElementsByTagName("dØdd"), ns_resolver] ]) generate_tests(test_xpath_throws, [ diff --git a/html/dom/reflection.js b/html/dom/reflection.js index c469bb0831239c..7dabcd4bf4dd54 100644 --- a/html/dom/reflection.js +++ b/html/dom/reflection.js @@ -638,8 +638,12 @@ ReflectionTests.doReflects = function(data, idlName, idlObj, domName, domObj) { data.nonCanon = {}; } for (var i = 0; i < data.keywords.length; i++) { - domTests.push(data.keywords[i], "x" + data.keywords[i], data.keywords[i] + "\0"); - idlTests.push(data.keywords[i], "x" + data.keywords[i], data.keywords[i] + "\0"); + if (data.keywords[i] != "") { + domTests.push(data.keywords[i], "x" + data.keywords[i], data.keywords[i] + "\0"); + } + if (data.keywords[i] != "") { + idlTests.push(data.keywords[i], "x" + data.keywords[i], data.keywords[i] + "\0"); + } if (data.keywords[i].length > 1) { domTests.push(data.keywords[i].slice(1)); diff --git a/html/semantics/forms/the-input-element/input-textselection-01.html b/html/semantics/forms/the-input-element/input-textselection-01.html index 3e1e79bd8dca7c..3508d23b0729cb 100644 --- a/html/semantics/forms/the-input-element/input-textselection-01.html +++ b/html/semantics/forms/the-input-element/input-textselection-01.html @@ -10,7 +10,7 @@ var valid = ["text", "search", "url", "tel", "email", "password"]; var invalid = ["hidden", "datetime", "date", "month", "week", "datetime-local", "number", "range", "color", "checkbox", "radio", "button", - "file", "submit", "image", "reset", "button"]; + "file", "submit", "image", "reset"]; valid.forEach(function(aType) { test(function() { var input = document.createElement("input"); diff --git a/html/webappapis/atob/base64.html b/html/webappapis/atob/base64.html index da95c1ae1e99f7..c33ab228f94a95 100644 --- a/html/webappapis/atob/base64.html +++ b/html/webappapis/atob/base64.html @@ -11,40 +11,40 @@ * btoa() as defined by the HTML5 spec, which mostly just references RFC4648. */ function mybtoa(s) { - // String conversion as required by WebIDL. - s = String(s); + // String conversion as required by WebIDL. + s = String(s); - // "The btoa() method must throw an INVALID_CHARACTER_ERR exception if the - // method's first argument contains any character whose code point is - // greater than U+00FF." - for (var i = 0; i < s.length; i++) { - if (s.charCodeAt(i) > 255) { - return "INVALID_CHARACTER_ERR"; - } - } + // "The btoa() method must throw an INVALID_CHARACTER_ERR exception if the + // method's first argument contains any character whose code point is + // greater than U+00FF." + for (var i = 0; i < s.length; i++) { + if (s.charCodeAt(i) > 255) { + return "INVALID_CHARACTER_ERR"; + } + } - var out = ""; - for (var i = 0; i < s.length; i += 3) { - var groupsOfSix = [undefined, undefined, undefined, undefined]; - groupsOfSix[0] = s.charCodeAt(i) >> 2; - groupsOfSix[1] = (s.charCodeAt(i) & 0x03) << 4; - if (s.length > i + 1) { - groupsOfSix[1] |= s.charCodeAt(i + 1) >> 4; - groupsOfSix[2] = (s.charCodeAt(i + 1) & 0x0f) << 2; - } - if (s.length > i + 2) { - groupsOfSix[2] |= s.charCodeAt(i + 2) >> 6; - groupsOfSix[3] = s.charCodeAt(i + 2) & 0x3f; - } - for (var j = 0; j < groupsOfSix.length; j++) { - if (typeof groupsOfSix[j] == "undefined") { - out += "="; - } else { - out += btoaLookup(groupsOfSix[j]); - } - } - } - return out; + var out = ""; + for (var i = 0; i < s.length; i += 3) { + var groupsOfSix = [undefined, undefined, undefined, undefined]; + groupsOfSix[0] = s.charCodeAt(i) >> 2; + groupsOfSix[1] = (s.charCodeAt(i) & 0x03) << 4; + if (s.length > i + 1) { + groupsOfSix[1] |= s.charCodeAt(i + 1) >> 4; + groupsOfSix[2] = (s.charCodeAt(i + 1) & 0x0f) << 2; + } + if (s.length > i + 2) { + groupsOfSix[2] |= s.charCodeAt(i + 2) >> 6; + groupsOfSix[3] = s.charCodeAt(i + 2) & 0x3f; + } + for (var j = 0; j < groupsOfSix.length; j++) { + if (typeof groupsOfSix[j] == "undefined") { + out += "="; + } else { + out += btoaLookup(groupsOfSix[j]); + } + } + } + return out; } /** @@ -52,22 +52,22 @@ * corresponding ASCII character. */ function btoaLookup(idx) { - if (idx < 26) { - return String.fromCharCode(idx + 'A'.charCodeAt(0)); - } - if (idx < 52) { - return String.fromCharCode(idx - 26 + 'a'.charCodeAt(0)); - } - if (idx < 62) { - return String.fromCharCode(idx - 52 + '0'.charCodeAt(0)); - } - if (idx == 62) { - return '+'; - } - if (idx == 63) { - return '/'; - } - // Throw INVALID_CHARACTER_ERR exception here -- won't be hit in the tests. + if (idx < 26) { + return String.fromCharCode(idx + 'A'.charCodeAt(0)); + } + if (idx < 52) { + return String.fromCharCode(idx - 26 + 'a'.charCodeAt(0)); + } + if (idx < 62) { + return String.fromCharCode(idx - 52 + '0'.charCodeAt(0)); + } + if (idx == 62) { + return '+'; + } + if (idx == 63) { + return '/'; + } + // Throw INVALID_CHARACTER_ERR exception here -- won't be hit in the tests. } /** @@ -75,94 +75,94 @@ * throwing INVALID_CHARACTER_ERR we return null. */ function myatob(input) { - // WebIDL requires DOMStrings to just be converted using ECMAScript - // ToString, which in our case amounts to calling String(). - input = String(input); + // WebIDL requires DOMStrings to just be converted using ECMAScript + // ToString, which in our case amounts to calling String(). + input = String(input); - // "Remove all space characters from input." - input = input.replace(/[ \t\n\f\r]/g, ""); + // "Remove all space characters from input." + input = input.replace(/[ \t\n\f\r]/g, ""); - // "If the length of input divides by 4 leaving no remainder, then: if - // input ends with one or two U+003D EQUALS SIGN (=) characters, remove - // them from input." - if (input.length % 4 == 0 && /==?$/.test(input)) { - input = input.replace(/==?$/, ""); - } + // "If the length of input divides by 4 leaving no remainder, then: if + // input ends with one or two U+003D EQUALS SIGN (=) characters, remove + // them from input." + if (input.length % 4 == 0 && /==?$/.test(input)) { + input = input.replace(/==?$/, ""); + } - // "If the length of input divides by 4 leaving a remainder of 1, throw an - // INVALID_CHARACTER_ERR exception and abort these steps." - // - // "If input contains a character that is not in the following list of - // characters and character ranges, throw an INVALID_CHARACTER_ERR - // exception and abort these steps: - // - // U+002B PLUS SIGN (+) - // U+002F SOLIDUS (/) - // U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9) - // U+0041 LATIN CAPITAL LETTER A to U+005A LATIN CAPITAL LETTER Z - // U+0061 LATIN SMALL LETTER A to U+007A LATIN SMALL LETTER Z" - if (input.length % 4 == 1 - || !/^[+/0-9A-Za-z]*$/.test(input)) { - return null; - } + // "If the length of input divides by 4 leaving a remainder of 1, throw an + // INVALID_CHARACTER_ERR exception and abort these steps." + // + // "If input contains a character that is not in the following list of + // characters and character ranges, throw an INVALID_CHARACTER_ERR + // exception and abort these steps: + // + // U+002B PLUS SIGN (+) + // U+002F SOLIDUS (/) + // U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9) + // U+0041 LATIN CAPITAL LETTER A to U+005A LATIN CAPITAL LETTER Z + // U+0061 LATIN SMALL LETTER A to U+007A LATIN SMALL LETTER Z" + if (input.length % 4 == 1 + || !/^[+/0-9A-Za-z]*$/.test(input)) { + return null; + } - // "Let output be a string, initially empty." - var output = ""; + // "Let output be a string, initially empty." + var output = ""; - // "Let buffer be a buffer that can have bits appended to it, initially - // empty." - // - // We append bits via left-shift and or. accumulatedBits is used to track - // when we've gotten to 24 bits. - var buffer = 0; - var accumulatedBits = 0; + // "Let buffer be a buffer that can have bits appended to it, initially + // empty." + // + // We append bits via left-shift and or. accumulatedBits is used to track + // when we've gotten to 24 bits. + var buffer = 0; + var accumulatedBits = 0; - // "While position does not point past the end of input, run these - // substeps:" - for (var i = 0; i < input.length; i++) { - // "Find the character pointed to by position in the first column of - // the following table. Let n be the number given in the second cell of - // the same row." - // - // "Append to buffer the six bits corresponding to number, most - // significant bit first." - // - // atobLookup() implements the table from the spec. - buffer <<= 6; - buffer |= atobLookup(input[i]); + // "While position does not point past the end of input, run these + // substeps:" + for (var i = 0; i < input.length; i++) { + // "Find the character pointed to by position in the first column of + // the following table. Let n be the number given in the second cell of + // the same row." + // + // "Append to buffer the six bits corresponding to number, most + // significant bit first." + // + // atobLookup() implements the table from the spec. + buffer <<= 6; + buffer |= atobLookup(input[i]); - // "If buffer has accumulated 24 bits, interpret them as three 8-bit - // big-endian numbers. Append the three characters with code points - // equal to those numbers to output, in the same order, and then empty - // buffer." - accumulatedBits += 6; - if (accumulatedBits == 24) { - output += String.fromCharCode((buffer & 0xff0000) >> 16); - output += String.fromCharCode((buffer & 0xff00) >> 8); - output += String.fromCharCode(buffer & 0xff); - buffer = accumulatedBits = 0; - } + // "If buffer has accumulated 24 bits, interpret them as three 8-bit + // big-endian numbers. Append the three characters with code points + // equal to those numbers to output, in the same order, and then empty + // buffer." + accumulatedBits += 6; + if (accumulatedBits == 24) { + output += String.fromCharCode((buffer & 0xff0000) >> 16); + output += String.fromCharCode((buffer & 0xff00) >> 8); + output += String.fromCharCode(buffer & 0xff); + buffer = accumulatedBits = 0; + } - // "Advance position by one character." - } + // "Advance position by one character." + } - // "If buffer is not empty, it contains either 12 or 18 bits. If it - // contains 12 bits, discard the last four and interpret the remaining - // eight as an 8-bit big-endian number. If it contains 18 bits, discard the - // last two and interpret the remaining 16 as two 8-bit big-endian numbers. - // Append the one or two characters with code points equal to those one or - // two numbers to output, in the same order." - if (accumulatedBits == 12) { - buffer >>= 4; - output += String.fromCharCode(buffer); - } else if (accumulatedBits == 18) { - buffer >>= 2; - output += String.fromCharCode((buffer & 0xff00) >> 8); - output += String.fromCharCode(buffer & 0xff); - } + // "If buffer is not empty, it contains either 12 or 18 bits. If it + // contains 12 bits, discard the last four and interpret the remaining + // eight as an 8-bit big-endian number. If it contains 18 bits, discard the + // last two and interpret the remaining 16 as two 8-bit big-endian numbers. + // Append the one or two characters with code points equal to those one or + // two numbers to output, in the same order." + if (accumulatedBits == 12) { + buffer >>= 4; + output += String.fromCharCode(buffer); + } else if (accumulatedBits == 18) { + buffer >>= 2; + output += String.fromCharCode((buffer & 0xff00) >> 8); + output += String.fromCharCode(buffer & 0xff); + } - // "Return output." - return output; + // "Return output." + return output; } /** @@ -170,63 +170,63 @@ * corresponding six-bit number. */ function atobLookup(chr) { - if (/[A-Z]/.test(chr)) { - return chr.charCodeAt(0) - "A".charCodeAt(0); - } - if (/[a-z]/.test(chr)) { - return chr.charCodeAt(0) - "a".charCodeAt(0) + 26; - } - if (/[0-9]/.test(chr)) { - return chr.charCodeAt(0) - "0".charCodeAt(0) + 52; - } - if (chr == "+") { - return 62; - } - if (chr == "/") { - return 63; - } - // Throw exception; should not be hit in tests + if (/[A-Z]/.test(chr)) { + return chr.charCodeAt(0) - "A".charCodeAt(0); + } + if (/[a-z]/.test(chr)) { + return chr.charCodeAt(0) - "a".charCodeAt(0) + 26; + } + if (/[0-9]/.test(chr)) { + return chr.charCodeAt(0) - "0".charCodeAt(0) + 52; + } + if (chr == "+") { + return 62; + } + if (chr == "/") { + return 63; + } + // Throw exception; should not be hit in tests } function btoaException(input) { - input = String(input); - for (var i = 0; i < input.length; i++) { - if (input.charCodeAt(i) > 255) { - return true; - } - } - return false; + input = String(input); + for (var i = 0; i < input.length; i++) { + if (input.charCodeAt(i) > 255) { + return true; + } + } + return false; } function testBtoa(input) { - // "The btoa() method must throw an INVALID_CHARACTER_ERR exception if the - // method's first argument contains any character whose code point is - // greater than U+00FF." - var normalizedInput = String(input); - for (var i = 0; i < normalizedInput.length; i++) { - if (normalizedInput.charCodeAt(i) > 255) { - assert_throws("InvalidCharacterError", function() { btoa(input); }, - "Code unit " + i + " has value " + normalizedInput.charCodeAt(i) + ", which is greater than 255"); - return; - } - } - assert_equals(btoa(input), mybtoa(input)); - assert_equals(atob(btoa(input)), String(input), "atob(btoa(input)) must be the same as String(input)"); + // "The btoa() method must throw an INVALID_CHARACTER_ERR exception if the + // method's first argument contains any character whose code point is + // greater than U+00FF." + var normalizedInput = String(input); + for (var i = 0; i < normalizedInput.length; i++) { + if (normalizedInput.charCodeAt(i) > 255) { + assert_throws("InvalidCharacterError", function() { btoa(input); }, + "Code unit " + i + " has value " + normalizedInput.charCodeAt(i) + ", which is greater than 255"); + return; + } + } + assert_equals(btoa(input), mybtoa(input)); + assert_equals(atob(btoa(input)), String(input), "atob(btoa(input)) must be the same as String(input)"); } -var tests = ["עברית", "", "a", "ab", "abc", "abcd", "abcde", - // This one is thrown in because IE9 seems to fail atob(btoa()) on it. Or - // possibly to fail btoa(). I actually can't tell what's happening here, - // but it doesn't hurt. - "\xff\xff\xc0", - // Is your DOM implementation binary-safe? - "\0", "\0a", "a\0b", - // WebIDL tests. - undefined, null, 7, 12, 1.5, true, false, NaN, +Infinity, -Infinity, 0, -0, - {toString: function() { return "foo" }}, +var tests = ["עברית", "", "ab", "abc", "abcd", "abcde", + // This one is thrown in because IE9 seems to fail atob(btoa()) on it. Or + // possibly to fail btoa(). I actually can't tell what's happening here, + // but it doesn't hurt. + "\xff\xff\xc0", + // Is your DOM implementation binary-safe? + "\0a", "a\0b", + // WebIDL tests. + undefined, null, 7, 12, 1.5, true, false, NaN, +Infinity, -Infinity, 0, -0, + {toString: function() { return "foo" }}, ]; for (var i = 0; i < 258; i++) { - tests.push(String.fromCharCode(i)); + tests.push(String.fromCharCode(i)); } tests.push(String.fromCharCode(10000)); tests.push(String.fromCharCode(65534)); @@ -235,71 +235,71 @@ // This is supposed to be U+10000. tests.push(String.fromCharCode(0xd800, 0xdc00)); tests = tests.map( - function(elem) { - var expected = mybtoa(elem); - if (expected === "INVALID_CHARACTER_ERR") { - return ["btoa(" + format_value(elem) + ") must raise INVALID_CHARACTER_ERR", elem]; - } - return ["btoa(" + format_value(elem) + ") == " + format_value(mybtoa(elem)), elem]; - } + function(elem) { + var expected = mybtoa(elem); + if (expected === "INVALID_CHARACTER_ERR") { + return ["btoa(" + format_value(elem) + ") must raise INVALID_CHARACTER_ERR", elem]; + } + return ["btoa(" + format_value(elem) + ") == " + format_value(mybtoa(elem)), elem]; + } ); var everything = ""; for (var i = 0; i < 256; i++) { - everything += String.fromCharCode(i); + everything += String.fromCharCode(i); } tests.push(["btoa(first 256 code points concatenated)", everything]); generate_tests(testBtoa, tests); function testAtob(input) { - var expected = myatob(input); - if (expected === null) { - assert_throws("InvalidCharacterError", function() { atob(input) }); - return; - } + var expected = myatob(input); + if (expected === null) { + assert_throws("InvalidCharacterError", function() { atob(input) }); + return; + } - assert_equals(atob(input), expected); + assert_equals(atob(input), expected); } -var tests = ["", "abcd", " abcd", "abcd ", "abcd===", " abcd===", "abcd=== ", - "abcd ===", "a", "ab", "abc", "abcde", String.fromCharCode(0xd800, 0xdc00), - "=", "==", "===", "====", "=====", - "a=", "a==", "a===", "a====", "a=====", - "ab=", "ab==", "ab===", "ab====", "ab=====", - "abc=", "abc==", "abc===", "abc====", "abc=====", - "abcd=", "abcd==", "abcd===", "abcd====", "abcd=====", - "abcde=", "abcde==", "abcde===", "abcde====", "abcde=====", - "=a", "=a=", "a=b", "a=b=", "ab=c", "ab=c=", "abc=d", "abc=d=", - // With whitespace - "ab\tcd", "ab\ncd", "ab\fcd", "ab\rcd", "ab cd", "ab\u00a0cd", - "ab\t\n\f\r cd", " \t\n\f\r ab\t\n\f\r cd\t\n\f\r ", - "ab\t\n\f\r =\t\n\f\r =\t\n\f\r ", - // Test if any bits are set at the end. These should all be fine, since - // they end with A, which becomes 0: - "A", "/A", "//A", "///A", "////A", - // These are all bad, since they end in / (= 63, all bits set) but their - // length isn't a multiple of four characters, so they can't be output by - // btoa(). Thus one might expect some UAs to throw exceptions or otherwise - // object, since they could never be output by btoa(), so they're good to - // test. - "/", "A/", "AA/", "AAAA/", - // But this one is possible: - "AAA/", - // Binary-safety tests - "\0", "\0nonsense", "abcd\0nonsense", - // WebIDL tests - undefined, null, 7, 12, 1.5, true, false, NaN, +Infinity, -Infinity, 0, -0, - {toString: function() { return "foo" }}, - {toString: function() { return "abcd" }}, +var tests = ["", "abcd", " abcd", "abcd ", " abcd===", "abcd=== ", + "abcd ===", "a", "ab", "abc", "abcde", String.fromCharCode(0xd800, 0xdc00), + "=", "==", "===", "====", "=====", + "a=", "a==", "a===", "a====", "a=====", + "ab=", "ab==", "ab===", "ab====", "ab=====", + "abc=", "abc==", "abc===", "abc====", "abc=====", + "abcd=", "abcd==", "abcd===", "abcd====", "abcd=====", + "abcde=", "abcde==", "abcde===", "abcde====", "abcde=====", + "=a", "=a=", "a=b", "a=b=", "ab=c", "ab=c=", "abc=d", "abc=d=", + // With whitespace + "ab\tcd", "ab\ncd", "ab\fcd", "ab\rcd", "ab cd", "ab\u00a0cd", + "ab\t\n\f\r cd", " \t\n\f\r ab\t\n\f\r cd\t\n\f\r ", + "ab\t\n\f\r =\t\n\f\r =\t\n\f\r ", + // Test if any bits are set at the end. These should all be fine, since + // they end with A, which becomes 0: + "A", "/A", "//A", "///A", "////A", + // These are all bad, since they end in / (= 63, all bits set) but their + // length isn't a multiple of four characters, so they can't be output by + // btoa(). Thus one might expect some UAs to throw exceptions or otherwise + // object, since they could never be output by btoa(), so they're good to + // test. + "/", "A/", "AA/", "AAAA/", + // But this one is possible: + "AAA/", + // Binary-safety tests + "\0nonsense", "abcd\0nonsense", + // WebIDL tests + undefined, null, 7, 12, 1.5, true, false, NaN, +Infinity, -Infinity, 0, -0, + {toString: function() { return "foo" }}, + {toString: function() { return "abcd" }}, ]; tests = tests.map( - function(elem) { - if (myatob(elem) === null) { - return ["atob(" + format_value(elem) + ") must raise InvalidCharacterError", elem]; - } - return ["atob(" + format_value(elem) + ") == " + format_value(myatob(elem)), elem]; - } + function(elem) { + if (myatob(elem) === null) { + return ["atob(" + format_value(elem) + ") must raise InvalidCharacterError", elem]; + } + return ["atob(" + format_value(elem) + ") == " + format_value(myatob(elem)), elem]; + } ); generate_tests(testAtob, tests); diff --git a/proximity/ProximityEvent_tests.html b/proximity/DeviceProximityEvent_tests.html similarity index 87% rename from proximity/ProximityEvent_tests.html rename to proximity/DeviceProximityEvent_tests.html index d89ec675566586..d4d08fda7f1080 100644 --- a/proximity/ProximityEvent_tests.html +++ b/proximity/DeviceProximityEvent_tests.html @@ -7,4 +7,4 @@

Test Suite for Proximity Events

- + diff --git a/proximity/UserProximityEvent_tests.html b/proximity/UserProximityEvent_tests.html new file mode 100644 index 00000000000000..f58550db0b7e27 --- /dev/null +++ b/proximity/UserProximityEvent_tests.html @@ -0,0 +1,10 @@ + + + +Proximity Events Test Suite +

Test Suite for Proximity Events

+
+ + + + diff --git a/proximity/UserProximityEvent_tests.js b/proximity/UserProximityEvent_tests.js index 871a938b0a1276..cac5bd58617588 100644 --- a/proximity/UserProximityEvent_tests.js +++ b/proximity/UserProximityEvent_tests.js @@ -331,7 +331,7 @@ t.done(); }); - var t2 = async_test('test if user proximity event received'); + var t2 = async_test('test if user proximity event received (idl attribute)'); window.onuserproximity = function(e) { t2.step(function() { var msg = 'expected instance of UserProximityEvent: '; diff --git a/selectors-api/tests/submissions/Opera/level2-lib.js b/selectors-api/tests/submissions/Opera/level2-lib.js index 5e8a680fc3290c..eb2c0f4b9c020c 100644 --- a/selectors-api/tests/submissions/Opera/level2-lib.js +++ b/selectors-api/tests/submissions/Opera/level2-lib.js @@ -200,7 +200,7 @@ function runValidSelectorTest(type, root, selectors, testType, docType) { //console.log("Running tests " + nodeType + ": " + s["testType"] + "&" + testType + "=" + (s["testType"] & testType) + ": " + JSON.stringify(s)) var foundall, found, context, refNodes, refArray; - if (s["testType"] & testType & (TEST_FIND_BASELINE | TEST_FIND_ADDITIONAL)) { + if (s["testType"] & testType & (TEST_FIND)) { /* @@ -314,7 +314,7 @@ function runValidSelectorTest(type, root, selectors, testType, docType) { } } - if (s["testType"] & testType & (TEST_QSA_BASELINE | TEST_QSA_ADDITIONAL)) { + if (s["testType"] & testType & (TEST_QSA)) { if (ctx && !ref) { // context.querySelectorAll(selector) // Only if refNodes is not specified } @@ -375,7 +375,7 @@ function runMatchesTest(type, root, selectors, testType, docType) { var ref = s["ref"]; if ((!s["exclude"] || (s["exclude"].indexOf(nodeType) === -1 && s["exclude"].indexOf(docType) === -1)) - && (s["testType"] & testType & (TEST_MATCH_BASELINE | TEST_MATCH_ADDITIONAL)) ) { + && (s["testType"] & testType & (TEST_MATCH)) ) { if (ctx && !ref) { test(function() {