Changeset 207520 in webkit


Ignore:
Timestamp:
Oct 18, 2016 10:03:11 PM (7 years ago)
Author:
rniwa@webkit.org
Message:

Import the latest custom elements tests from W3C
https://bugs.webkit.org/show_bug.cgi?id=163640

Reviewed by Chris Dumez.

LayoutTests/imported/w3c:

Import more custom elements tests from web-platform-tests as of fbe5ac0fd8eecac67d1562032eeba5bd7ec2b735.
Most of these tests are written and fixed by me.

  • web-platform-tests/custom-elements/htmlconstructor/newtarget-expected.txt:
  • web-platform-tests/custom-elements/htmlconstructor/newtarget.html:
  • web-platform-tests/custom-elements/reactions/DOMStringMap-expected.txt: Added.
  • web-platform-tests/custom-elements/reactions/DOMStringMap.html: Added.
  • web-platform-tests/custom-elements/reactions/Document-expected.txt:
  • web-platform-tests/custom-elements/reactions/Document.html:
  • web-platform-tests/custom-elements/reactions/Element-expected.txt:
  • web-platform-tests/custom-elements/reactions/Element.html:
  • web-platform-tests/custom-elements/reactions/ElementContentEditable-expected.txt: Added.
  • web-platform-tests/custom-elements/reactions/ElementContentEditable.html: Added.
  • web-platform-tests/custom-elements/reactions/HTMLElement-expected.txt: Added.
  • web-platform-tests/custom-elements/reactions/HTMLElement.html: Added.
  • web-platform-tests/custom-elements/reactions/NamedNodeMap-expected.txt:
  • web-platform-tests/custom-elements/reactions/NamedNodeMap.html:
  • web-platform-tests/custom-elements/reactions/Range-expected.txt:
  • web-platform-tests/custom-elements/reactions/Range.html:
  • web-platform-tests/custom-elements/reactions/Selection-expected.txt: Added.
  • web-platform-tests/custom-elements/reactions/Selection.html: Added.
  • web-platform-tests/custom-elements/reactions/resources/reactions.js:
  • web-platform-tests/custom-elements/reactions/w3c-import.log:
  • web-platform-tests/custom-elements/resources/custom-elements-helpers.js:

LayoutTests:

Removed the test re-imported via web-platform-tests in r206838.

  • fast/custom-elements/lifecycle-callback-timing-expected.txt: Removed.
  • fast/custom-elements/lifecycle-callback-timing.html: Removed.
Location:
trunk/LayoutTests
Files:
8 added
2 deleted
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r207519 r207520  
     12016-10-18  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        Import the latest custom elements tests from W3C
     4        https://bugs.webkit.org/show_bug.cgi?id=163640
     5
     6        Reviewed by Chris Dumez.
     7
     8        Removed the test re-imported via web-platform-tests in r206838.
     9
     10        * fast/custom-elements/lifecycle-callback-timing-expected.txt: Removed.
     11        * fast/custom-elements/lifecycle-callback-timing.html: Removed.
     12
    1132016-10-18  Chris Dumez  <cdumez@apple.com>
    214
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r207514 r207520  
     12016-10-18  Ryosuke Niwa  <rniwa@webkit.org>
     2
     3        Import the latest custom elements tests from W3C
     4        https://bugs.webkit.org/show_bug.cgi?id=163640
     5
     6        Reviewed by Chris Dumez.
     7
     8        Import more custom elements tests from web-platform-tests as of fbe5ac0fd8eecac67d1562032eeba5bd7ec2b735.
     9        Most of these tests are written and fixed by me.
     10
     11        * web-platform-tests/custom-elements/htmlconstructor/newtarget-expected.txt:
     12        * web-platform-tests/custom-elements/htmlconstructor/newtarget.html:
     13        * web-platform-tests/custom-elements/reactions/DOMStringMap-expected.txt: Added.
     14        * web-platform-tests/custom-elements/reactions/DOMStringMap.html: Added.
     15        * web-platform-tests/custom-elements/reactions/Document-expected.txt:
     16        * web-platform-tests/custom-elements/reactions/Document.html:
     17        * web-platform-tests/custom-elements/reactions/Element-expected.txt:
     18        * web-platform-tests/custom-elements/reactions/Element.html:
     19        * web-platform-tests/custom-elements/reactions/ElementContentEditable-expected.txt: Added.
     20        * web-platform-tests/custom-elements/reactions/ElementContentEditable.html: Added.
     21        * web-platform-tests/custom-elements/reactions/HTMLElement-expected.txt: Added.
     22        * web-platform-tests/custom-elements/reactions/HTMLElement.html: Added.
     23        * web-platform-tests/custom-elements/reactions/NamedNodeMap-expected.txt:
     24        * web-platform-tests/custom-elements/reactions/NamedNodeMap.html:
     25        * web-platform-tests/custom-elements/reactions/Range-expected.txt:
     26        * web-platform-tests/custom-elements/reactions/Range.html:
     27        * web-platform-tests/custom-elements/reactions/Selection-expected.txt: Added.
     28        * web-platform-tests/custom-elements/reactions/Selection.html: Added.
     29        * web-platform-tests/custom-elements/reactions/resources/reactions.js:
     30        * web-platform-tests/custom-elements/reactions/w3c-import.log:
     31        * web-platform-tests/custom-elements/resources/custom-elements-helpers.js:
     32
    1332016-10-18  Chris Dumez  <cdumez@apple.com>
    234
  • trunk/LayoutTests/imported/w3c/web-platform-tests/custom-elements/htmlconstructor/newtarget-expected.txt

    r206838 r207520  
    11
    2 FAIL Use NewTarget's prototype, not the one stored at definition time promise_test: Unhandled rejection with value: object "TypeError: null is not an object (evaluating 'document.bo..."
    3 FAIL Rethrow any exceptions thrown while getting the prototype assert_throws: function "() => {
    4       return Reflect.construct(w.HTMLElement, [],..." threw object "TypeError: new.target does not define a custom element" ("TypeError") expected object "[object Object]" ("prototype throws")
    5 FAIL If prototype is not object, derives the fallback from NewTarget's realm (autonomous custom elements) promise_test: Unhandled rejection with value: object "TypeError: new.target does not define a custom element"
    6 FAIL If prototype is not object, derives the fallback from NewTarget's realm (customized built-in elements) promise_test: Unhandled rejection with value: object "TypeError: Reflect.construct requires the first argument ..."
     2PASS Use NewTarget's prototype, not the one stored at definition time
     3PASS Rethrow any exceptions thrown while getting the prototype
     4FAIL If prototype is not object (null), derives the fallback from NewTarget's realm (autonomous custom elements) assert_equals: Must use the HTMLElement from the realm of NewTarget expected object "[object HTMLElementPrototype]" but got object "[object HTMLElementPrototype]"
     5FAIL If prototype is not object (undefined), derives the fallback from NewTarget's realm (autonomous custom elements) assert_equals: Must use the HTMLElement from the realm of NewTarget expected object "[object HTMLElementPrototype]" but got object "[object HTMLElementPrototype]"
     6FAIL If prototype is not object (5), derives the fallback from NewTarget's realm (autonomous custom elements) assert_equals: Must use the HTMLElement from the realm of NewTarget expected object "[object HTMLElementPrototype]" but got object "[object HTMLElementPrototype]"
     7FAIL If prototype is not object (string), derives the fallback from NewTarget's realm (autonomous custom elements) assert_equals: Must use the HTMLElement from the realm of NewTarget expected object "[object HTMLElementPrototype]" but got object "[object HTMLElementPrototype]"
     8FAIL If prototype is not object (null), derives the fallback from NewTarget's realm (customized built-in elements) promise_test: Unhandled rejection with value: object "TypeError: Reflect.construct requires the first argument ..."
     9FAIL If prototype is not object (undefined), derives the fallback from NewTarget's realm (customized built-in elements) promise_test: Unhandled rejection with value: object "TypeError: Reflect.construct requires the first argument ..."
     10FAIL If prototype is not object (5), derives the fallback from NewTarget's realm (customized built-in elements) promise_test: Unhandled rejection with value: object "TypeError: Reflect.construct requires the first argument ..."
     11FAIL If prototype is not object (string), derives the fallback from NewTarget's realm (customized built-in elements) promise_test: Unhandled rejection with value: object "TypeError: Reflect.construct requires the first argument ..."
    712
  • trunk/LayoutTests/imported/w3c/web-platform-tests/custom-elements/htmlconstructor/newtarget.html

    r206999 r207520  
    66<script src="/resources/testharnessreport.js"></script>
    77<script src="../resources/custom-elements-helpers.js"></script>
    8 
     8<body>
    99<script>
    1010"use strict";
    1111
    1212test_with_window(w => {
    13   let afterDefinition = false;
     13  let beforeDefinition = true;
    1414  const proto1 = { "proto": "number one" };
    1515  const proto2 = { "proto": "number two" };
    1616
    17   const TestElement = (function () {
    18     assert_throws({ name: "prototype throws" }, () => {
    19       const o = Reflect.construct(w.HTMLElement, [], new.target);
     17  function TestElement() {
     18    const o = Reflect.construct(w.HTMLElement, [], new.target);
     19    assert_equals(Object.getPrototypeOf(o), proto2,
     20      "Must use the value returned from new.target.prototype");
     21    assert_not_equals(Object.getPrototypeOf(o), proto1,
     22      "Must not use the prototype stored at definition time");
     23  }
    2024
    21       assert_equals(Object.getPrototypeOf(o), proto2,
    22         "Must use the value returned from new.target.prototype");
    23       assert_not_equals(Object.getPrototypeOf(o), proto1,
    24         "Must not use the prototype stored at definition time");
    25     });
    26   }).bind({});
    27 
    28   Object.defineProperty(TestElement, "prototype", {
    29     get() {
    30       return beforeDefinition ? proto1 : proto2;
    31     }
     25  const ElementWithDynamicPrototype = new Proxy(TestElement, {
     26      get: function (target, name) {
     27        if (name == "prototype")
     28          return beforeDefinition ? proto1 : proto2;
     29        return target[name];
     30      }
    3231  });
    3332
    34   w.customElements.define("test-element", TestElement);
     33  w.customElements.define("test-element", ElementWithDynamicPrototype);
    3534
    36   beforeDefinition = true;
    37   new TestElement();
    38 
     35  beforeDefinition = false;
     36  new ElementWithDynamicPrototype();
    3937}, "Use NewTarget's prototype, not the one stored at definition time");
    4038
     
    4341  let throws = false;
    4442
    45   const TestElement = (function () {
     43  function TestElement() {
     44    throws = true;
    4645    assert_throws({ name: "prototype throws" }, () => {
    47       return Reflect.construct(w.HTMLElement, [], new.target);
     46      Reflect.construct(w.HTMLElement, [], new.target);
    4847    });
    49   }).bind({});
     48  }
    5049
    51   Object.defineProperty(TestElement, "prototype", {
    52     get() {
    53       if (throws) {
     50  const ElementWithDynamicPrototype = new Proxy(TestElement, {
     51    get: function (target, name) {
     52      if (throws && name == "prototype")
    5453        throw { name: "prototype throws" };
    55       }
    56       return {};
     54      return target[name];
    5755    }
    5856  });
    5957
    60   w.customElements.define("test-element", TestElement);
     58  w.customElements.define("test-element", ElementWithDynamicPrototype);
    6159
    62   throws = true;
    63   new TestElement();
     60  new ElementWithDynamicPrototype();
    6461
    6562}, "Rethrow any exceptions thrown while getting the prototype");
    6663
    67 test_with_window(w => {
    68   for (const notAnObject of [null, undefined, 5, "string"]) {
     64[null, undefined, 5, "string"].forEach(function (notAnObject) {
     65  test_with_window(w => {
    6966    // We have to return an object during define(), but not during super()
    7067    let returnNotAnObject = false;
    7168
    72     const TestElement = (function () {
     69    function TestElement() {
    7370      const o = Reflect.construct(w.HTMLElement, [], new.target);
    7471
    75       assert_equals(Object.getPrototypeOf(o), window.HTMLElement,
     72      assert_equals(Object.getPrototypeOf(new.target), window.Function.prototype);
     73      assert_equals(Object.getPrototypeOf(o), window.HTMLElement.prototype,
    7674        "Must use the HTMLElement from the realm of NewTarget");
    77       assert_not_equals(Object.getPrototypeOf(o), w.HTMLElement,
     75      assert_not_equals(Object.getPrototypeOf(o), w.HTMLElement.prototype,
    7876        "Must not use the HTMLElement from the realm of the active function object (w.HTMLElement)");
    7977
    8078      return o;
    81     }).bind({});
     79    }
    8280
    83     Object.defineProperty(TestElement, "prototype", {
    84       get() {
    85         return returnNotAnObject ? notAnObject : {};
     81    const ElementWithDynamicPrototype = new Proxy(TestElement, {
     82      get: function (target, name) {
     83        if (name == "prototype")
     84          return returnNotAnObject ? notAnObject : {};
     85        return target[name];
    8686      }
    8787    });
    8888
    89     w.customElements.define("test-element", TestElement);
     89    w.customElements.define("test-element", ElementWithDynamicPrototype);
    9090
    9191    returnNotAnObject = true;
    92     new TestElement();
    93   }
    94 }, "If prototype is not object, derives the fallback from NewTarget's realm (autonomous custom elements)");
     92    new ElementWithDynamicPrototype();
     93  }, "If prototype is not object (" + notAnObject + "), derives the fallback from NewTarget's realm (autonomous custom elements)");
     94});
    9595
    96 test_with_window(w => {
    97   for (const notAnObject of [null, undefined, 5, "string"]) {
     96[null, undefined, 5, "string"].forEach(function (notAnObject) {
     97  test_with_window(w => {
    9898    // We have to return an object during define(), but not during super()
    9999    let returnNotAnObject = false;
    100100
    101     const TestElement = (function () {
     101    function TestElement() {
    102102      const o = Reflect.construct(w.HTMLParagraphElement, [], new.target);
    103103
     
    108108
    109109      return o;
    110     }).bind({});
     110    }
    111111
    112     Object.defineProperty(TestElement, "prototype", {
    113       get() {
    114         return returnNotAnObject ? notAnObject : {};
     112    const ElementWithDynamicPrototype = new Proxy(TestElement, {
     113      get: function (target, name) {
     114        if (name == "prototype")
     115          return returnNotAnObject ? notAnObject : {};
     116        return target[name];
    115117      }
    116118    });
    117119
    118     w.customElements.define("test-element", TestElement, { extends: "p" });
     120    w.customElements.define("test-element", ElementWithDynamicPrototype, { extends: "p" });
    119121
    120122    returnNotAnObject = true;
    121     new TestElement();
    122   }
    123 }, "If prototype is not object, derives the fallback from NewTarget's realm (customized built-in elements)");
     123    new ElementWithDynamicPrototype();
     124  }, "If prototype is not object (" + notAnObject + "), derives the fallback from NewTarget's realm (customized built-in elements)");
     125});
     126
    124127</script>
     128</body>
  • trunk/LayoutTests/imported/w3c/web-platform-tests/custom-elements/reactions/Document-expected.txt

    r207170 r207520  
    22FAIL importNode on Document must construct a new custom element when importing a custom element assert_array_equals: lengths differ, expected 1 got 0
    33PASS adoptNode on Document must enqueue an adopted reaction when importing a custom element
     4FAIL execCommand on Document must enqueue a disconnected reaction when deleting a custom element from a contenteditable element assert_array_equals: lengths differ, expected 1 got 0
    45
  • trunk/LayoutTests/imported/w3c/web-platform-tests/custom-elements/reactions/Document.html

    r206999 r207520  
    22<html>
    33<head>
    4 <title>Custom Elements: CEReactions on ParentNode interface</title>
     4<title>Custom Elements: CEReactions on Document interface</title>
    55<meta name="author" title="Ryosuke Niwa" href="mailto:rniwa@webkit.org">
    66<meta name="assert" content="importNode and adoptNode of Document interface must have CEReactions">
    77<meta name="help" content="https://dom.spec.whatwg.org/#document">
     8<meta name="help" content="https://html.spec.whatwg.org/#document">
    89<script src="/resources/testharness.js"></script>
    910<script src="/resources/testharnessreport.js"></script>
     
    4344}, 'adoptNode on Document must enqueue an adopted reaction when importing a custom element');
    4445
     46test(function () {
     47    var element = define_new_custom_element();
     48    var instance = document.createElement(element.name);
     49
     50    var container = document.createElement('div');
     51    container.contentEditable = true;
     52    container.appendChild(instance);
     53    document.body.appendChild(container);
     54
     55    assert_array_equals(element.takeLog().types(), ['constructed', 'connected']);
     56
     57    container.focus();
     58    document.execCommand('delete', false, null);
     59
     60    assert_array_equals(element.takeLog().types(), ['disconnected']);
     61}, 'execCommand on Document must enqueue a disconnected reaction when deleting a custom element from a contenteditable element');
     62
    4563</script>
    4664</body>
  • trunk/LayoutTests/imported/w3c/web-platform-tests/custom-elements/reactions/Element-expected.txt

    r207170 r207520  
    1414PASS setAttributeNS on Element must enqueue an attributeChanged reaction when replacing an existing attribute
    1515PASS setAttributeNS on Element must enqueue an attributeChanged reaction when replacing an existing unobserved attribute
    16 PASS removeAttribute on Element must not enqueue an attributeChanged reaction when removing an attribute that does not exist
    1716PASS removeAttribute on Element must not enqueue an attributeChanged reaction when removing an unobserved attribute
    1817PASS removeAttribute on Element must enqueue an attributeChanged reaction when removing an existing attribute
    1918PASS removeAttribute on Element must not enqueue an attributeChanged reaction when removing an existing unobserved attribute
    20 PASS removeAttributeNS on Element must not enqueue an attributeChanged reaction when removing an attribute that does not exist
    2119PASS removeAttributeNS on Element must not enqueue an attributeChanged reaction when removing an unobserved attribute
    2220PASS removeAttributeNS on Element must enqueue an attributeChanged reaction when removing an existing attribute
     
    3028PASS setAttributeNodeNS on Element must enqueue an attributeChanged reaction when replacing an existing attribute
    3129PASS setAttributeNodeNS on Element must enqueue an attributeChanged reaction when replacing an existing unobserved attribute
    32 PASS removeAttributeNode on Element must not enqueue an attributeChanged reaction when removing an attribute that does not exist
    3330PASS removeAttributeNode on Element must not enqueue an attributeChanged reaction when removing an unobserved attribute
    3431PASS removeAttributeNode on Element must enqueue an attributeChanged reaction when removing an existing attribute
    3532PASS removeAttributeNode on Element must not enqueue an attributeChanged reaction when removing an existing unobserved attribute
    36 PASS undefined must enqueue a connected reaction
    37 PASS undefined must enqueue a disconnected reaction, an adopted reaction, and a connected reaction when the custom element was in another document
     33PASS insertAdjacentElement on Element must enqueue a connected reaction
     34PASS insertAdjacentElement on Element must enqueue a disconnected reaction, an adopted reaction, and a connected reaction when the custom element was in another document
     35FAIL innerHTML on Element must enqueue a connected reaction for a newly constructed custom element assert_array_equals: lengths differ, expected 2 got 1
     36FAIL innerHTML on Element must enqueue a attributeChanged reaction for a newly constructed custom element assert_array_equals: lengths differ, expected 3 got 1
     37FAIL innerHTML on Element must enqueue a disconnected reaction assert_array_equals: lengths differ, expected 1 got 0
     38FAIL outerHTML on Element must enqueue a connected reaction for a newly constructed custom element assert_array_equals: lengths differ, expected 2 got 1
     39FAIL outerHTML on Element must enqueue a attributeChanged reaction for a newly constructed custom element assert_array_equals: lengths differ, expected 3 got 1
     40FAIL outerHTML on Element must enqueue a disconnected reaction assert_array_equals: lengths differ, expected 1 got 0
     41FAIL insertAdjacentHTML on Element must enqueue a connected reaction for a newly constructed custom element assert_array_equals: lengths differ, expected 2 got 1
     42FAIL insertAdjacentHTML on Element must enqueue a attributeChanged reaction for a newly constructed custom element assert_array_equals: lengths differ, expected 3 got 1
    3843
  • trunk/LayoutTests/imported/w3c/web-platform-tests/custom-elements/reactions/Element.html

    r206999 r207520  
    22<html>
    33<head>
    4 <title>Custom Elements: CEReactions on Node interface</title>
     4<title>Custom Elements: CEReactions on Element interface</title>
    55<meta name="author" title="Ryosuke Niwa" href="mailto:rniwa@webkit.org">
    6 <meta name="assert" content="id, className, slot, setAttribute, setAttributeNS, removeAttribute, removeAttributeNS, setAttributeNode, setAttributeNodeNS, removeAttributeNode, and insertAdjacentElement of Element interface must have CEReactions">
     6<meta name="assert" content="id, className, slot, setAttribute, setAttributeNS, removeAttribute, removeAttributeNS, setAttributeNode, setAttributeNodeNS, removeAttributeNode, insertAdjacentElement, innerHTML, outerHTML, and insertAdjacentHTML of Element interface must have CEReactions">
    77<meta name="help" content="https://dom.spec.whatwg.org/#element">
     8<meta name="help" content="https://w3c.github.io/DOM-Parsing/">
    89<script src="/resources/testharness.js"></script>
    910<script src="/resources/testharnessreport.js"></script>
     
    5556testNodeConnector(function (newContainer, element) {
    5657    newContainer.insertAdjacentElement('afterBegin', element);
    57 });
     58}, 'insertAdjacentElement on Element');
     59
     60testInsertingMarkup(function (newContainer, markup) {
     61    newContainer.innerHTML = markup;
     62}, 'innerHTML on Element');
     63
     64testNodeDisconnector(function (customElement) {
     65    customElement.parentNode.innerHTML = '';
     66}, 'innerHTML on Element');
     67
     68testInsertingMarkup(function (newContainer, markup) {
     69    newContainer.firstChild.outerHTML = markup;
     70}, 'outerHTML on Element');
     71
     72testNodeDisconnector(function (customElement) {
     73    customElement.outerHTML = '';
     74}, 'outerHTML on Element');
     75
     76testInsertingMarkup(function (newContainer, markup) {
     77    newContainer.insertAdjacentHTML('afterBegin', markup);
     78}, 'insertAdjacentHTML on Element');
    5879
    5980</script>
  • trunk/LayoutTests/imported/w3c/web-platform-tests/custom-elements/reactions/NamedNodeMap-expected.txt

    r207170 r207520  
    88PASS setNamedItemNS on NamedNodeMap must enqueue an attributeChanged reaction when replacing an existing attribute
    99PASS setNamedItemNS on NamedNodeMap must enqueue an attributeChanged reaction when replacing an existing unobserved attribute
    10 FAIL removeNamedItem on NamedNodeMap must not enqueue an attributeChanged reaction when removing an attribute that does not exist The object can not be found here.
    1110PASS removeNamedItem on NamedNodeMap must not enqueue an attributeChanged reaction when removing an unobserved attribute
    1211PASS removeNamedItem on NamedNodeMap must enqueue an attributeChanged reaction when removing an existing attribute
    1312PASS removeNamedItem on NamedNodeMap must not enqueue an attributeChanged reaction when removing an existing unobserved attribute
    14 FAIL removeNamedItemNS on NamedNodeMap must not enqueue an attributeChanged reaction when removing an attribute that does not exist The object can not be found here.
    1513PASS removeNamedItemNS on NamedNodeMap must not enqueue an attributeChanged reaction when removing an unobserved attribute
    1614PASS removeNamedItemNS on NamedNodeMap must enqueue an attributeChanged reaction when removing an existing attribute
  • trunk/LayoutTests/imported/w3c/web-platform-tests/custom-elements/reactions/NamedNodeMap.html

    r206999 r207520  
    2929testAttributeRemover(function (element, name) {
    3030    element.attributes.removeNamedItem(name);
    31 }, 'removeNamedItem on NamedNodeMap');
     31}, 'removeNamedItem on NamedNodeMap', {onlyExistingAttribute: true});
    3232
    3333testAttributeRemover(function (element, name) {
    3434    element.attributes.removeNamedItemNS(null, name);
    35 }, 'removeNamedItemNS on NamedNodeMap');
     35}, 'removeNamedItemNS on NamedNodeMap', {onlyExistingAttribute: true});
    3636
    3737</script>
  • trunk/LayoutTests/imported/w3c/web-platform-tests/custom-elements/reactions/Range-expected.txt

    r207170 r207520  
    77PASS insertNode on Range must enqueue a connected reaction
    88PASS insertNode on Range must enqueue a disconnected reaction, an adopted reaction, and a connected reaction when the custom element was in another document
    9 PASS insertNode on Range must enqueue a connected reaction
    10 PASS insertNode on Range must enqueue a disconnected reaction, an adopted reaction, and a connected reaction when the custom element was in another document
     9PASS surroundContents on Range must enqueue a connected reaction
     10PASS surroundContents on Range must enqueue a disconnected reaction, an adopted reaction, and a connected reaction when the custom element was in another document
     11FAIL createContextualFragment on Range must construct a custom element assert_equals: expected (function) function "class CustomElement extends HTMLElement {
     12        constru..." but got (object) object "[object Object]"
    1113
  • trunk/LayoutTests/imported/w3c/web-platform-tests/custom-elements/reactions/Range.html

    r206999 r207520  
    4343    range.selectNodeContents(container);
    4444    range.surroundContents(customElement);
    45 }, 'insertNode on Range');
     45}, 'surroundContents on Range');
     46
     47testParsingMarkup(function (document, markup) {
     48    var range = document.createRange();
     49    return range.createContextualFragment(markup);
     50}, 'createContextualFragment on Range');
    4651
    4752</script>
  • trunk/LayoutTests/imported/w3c/web-platform-tests/custom-elements/reactions/resources/reactions.js

    r206999 r207520  
    4040        container.appendChild(instance);
    4141        assert_array_equals(element.takeLog().types(), ['connected']);
    42         testFunction(instance);
     42        testFunction(instance, window);
    4343        assert_array_equals(element.takeLog().types(), ['disconnected']);
    4444    }, name + ' must enqueue a disconnected reaction');
    4545
    4646    container.parentNode.removeChild(container);
     47}
     48
     49function testInsertingMarkup(testFunction, name) {
     50    let container = document.createElement('div');
     51    container.appendChild(document.createElement('div'));
     52    document.body.appendChild(container);
     53
     54    test(function () {
     55        var element = define_new_custom_element();
     56        testFunction(container, `<${element.name}></${element.name}>`);
     57        assert_array_equals(element.takeLog().types(), ['constructed', 'connected']);
     58    }, name + ' must enqueue a connected reaction for a newly constructed custom element');
     59
     60    test(function () {
     61        var element = define_new_custom_element(['title']);
     62        testFunction(container, `<${element.name} id="hello" title="hi"></${element.name}>`);
     63        var logEntries = element.takeLog();
     64        assert_array_equals(logEntries.types(), ['constructed', 'attributeChanged', 'connected']);
     65        assert_attribute_log_entry(logEntries[1], {name: 'title', oldValue: null, newValue: 'hi', namespace: null});
     66    }, name + ' must enqueue a attributeChanged reaction for a newly constructed custom element');
     67
     68    container.parentNode.removeChild(container);
     69}
     70
     71function testParsingMarkup(testFunction, name) {
     72    test(function () {
     73        var element = define_new_custom_element(['id']);
     74        assert_array_equals(element.takeLog().types(), []);
     75        var instance = testFunction(document, `<${element.name} id="hello" class="foo"></${element.name}>`);
     76        assert_equals(Object.getPrototypeOf(instance.querySelector(element.name)), element.class);
     77        var logEntries = element.takeLog();
     78        assert_array_equals(logEntries.types(), ['constructed', 'attributeChanged']);
     79        assert_attribute_log_entry(logEntries[1], {name: 'id', oldValue: null, newValue: 'hello', namespace: null});
     80    }, name + ' must construct a custom element');
    4781}
    4882
     
    93127}
    94128
     129function testReflectAttributeWithContentValues(jsAttributeName, contentAttributeName, validValue1, contentValue1, validValue2, contentValue2, name) {
     130    test(function () {
     131        var element = define_new_custom_element([contentAttributeName]);
     132        var instance = document.createElement(element.name);
     133        assert_array_equals(element.takeLog().types(), ['constructed']);
     134        instance[jsAttributeName] = validValue1;
     135        var logEntries = element.takeLog();
     136        assert_array_equals(logEntries.types(), ['attributeChanged']);
     137
     138        assert_attribute_log_entry(logEntries.last(), {name: contentAttributeName, oldValue: null, newValue: contentValue1, namespace: null});
     139    }, name + ' must enqueue an attributeChanged reaction when adding ' + contentAttributeName + ' content attribute');
     140
     141    test(function () {
     142        var element = define_new_custom_element([contentAttributeName]);
     143        var instance = document.createElement(element.name);
     144        instance[jsAttributeName] = validValue1;
     145        assert_array_equals(element.takeLog().types(), ['constructed', 'attributeChanged']);
     146        instance[jsAttributeName] = validValue2;
     147        var logEntries = element.takeLog();
     148        assert_array_equals(logEntries.types(), ['attributeChanged']);
     149        assert_attribute_log_entry(logEntries.last(), {name: contentAttributeName, oldValue: contentValue1, newValue: contentValue2, namespace: null});
     150    }, name + ' must enqueue an attributeChanged reaction when replacing an existing attribute');
     151}
     152
    95153function testReflectAttribute(jsAttributeName, contentAttributeName, validValue1, validValue2, name) {
    96     test(function () {
    97         var element = define_new_custom_element([contentAttributeName]);
    98         var instance = document.createElement(element.name);
    99         assert_array_equals(element.takeLog().types(), ['constructed']);
    100         instance[jsAttributeName] = validValue1;
    101         var logEntries = element.takeLog();
    102         assert_array_equals(logEntries.types(), ['attributeChanged']);
    103         assert_attribute_log_entry(logEntries.last(), {name: contentAttributeName, oldValue: null, newValue: validValue1, namespace: null});
    104     }, name + ' must enqueue an attributeChanged reaction when adding ' + contentAttributeName + ' content attribute');
    105 
    106     test(function () {
    107         var element = define_new_custom_element([contentAttributeName]);
    108         var instance = document.createElement(element.name);
    109         instance[jsAttributeName] = validValue1;
    110         assert_array_equals(element.takeLog().types(), ['constructed', 'attributeChanged']);
    111         instance[jsAttributeName] = validValue2;
    112         var logEntries = element.takeLog();
    113         assert_array_equals(logEntries.types(), ['attributeChanged']);
    114         assert_attribute_log_entry(logEntries.last(), {name: contentAttributeName, oldValue: validValue1, newValue: validValue2, namespace: null});
    115     }, name + ' must enqueue an attributeChanged reaction when replacing an existing attribute');
     154    testReflectAttributeWithContentValues(jsAttributeName, contentAttributeName, validValue1, validValue1, validValue2, validValue2, name);
     155}
     156
     157function testReflectBooleanAttribute(jsAttributeName, contentAttributeName, name) {
     158    testReflectAttributeWithContentValues(jsAttributeName, contentAttributeName, true, '', false, null, name);
    116159}
    117160
     
    178221}
    179222
    180 function testAttributeRemover(testFunction, name) {
    181     test(function () {
    182         var element = define_new_custom_element(['title']);
    183         var instance = document.createElement(element.name);
    184         assert_array_equals(element.takeLog().types(), ['constructed']);
    185         testFunction(instance, 'title');
    186         assert_array_equals(element.takeLog().types(), []);
    187     }, name + ' must not enqueue an attributeChanged reaction when removing an attribute that does not exist');
     223function testAttributeRemover(testFunction, name, options) {
     224    if (options && !options.onlyExistingAttribute) {
     225        test(function () {
     226            var element = define_new_custom_element(['title']);
     227            var instance = document.createElement(element.name);
     228            assert_array_equals(element.takeLog().types(), ['constructed']);
     229            testFunction(instance, 'title');
     230            assert_array_equals(element.takeLog().types(), []);
     231        }, name + ' must not enqueue an attributeChanged reaction when removing an attribute that does not exist');
     232    }
    188233
    189234    test(function () {
  • trunk/LayoutTests/imported/w3c/web-platform-tests/custom-elements/reactions/w3c-import.log

    r206838 r207520  
    1818/LayoutTests/imported/w3c/web-platform-tests/custom-elements/reactions/Attr.html
    1919/LayoutTests/imported/w3c/web-platform-tests/custom-elements/reactions/ChildNode.html
     20/LayoutTests/imported/w3c/web-platform-tests/custom-elements/reactions/DOMStringMap.html
    2021/LayoutTests/imported/w3c/web-platform-tests/custom-elements/reactions/DOMTokenList.html
    2122/LayoutTests/imported/w3c/web-platform-tests/custom-elements/reactions/Document.html
    2223/LayoutTests/imported/w3c/web-platform-tests/custom-elements/reactions/Element.html
     24/LayoutTests/imported/w3c/web-platform-tests/custom-elements/reactions/ElementContentEditable.html
     25/LayoutTests/imported/w3c/web-platform-tests/custom-elements/reactions/HTMLElement.html
    2326/LayoutTests/imported/w3c/web-platform-tests/custom-elements/reactions/NamedNodeMap.html
    2427/LayoutTests/imported/w3c/web-platform-tests/custom-elements/reactions/Node.html
    2528/LayoutTests/imported/w3c/web-platform-tests/custom-elements/reactions/ParentNode.html
    2629/LayoutTests/imported/w3c/web-platform-tests/custom-elements/reactions/Range.html
     30/LayoutTests/imported/w3c/web-platform-tests/custom-elements/reactions/Selection.html
  • trunk/LayoutTests/imported/w3c/web-platform-tests/custom-elements/resources/custom-elements-helpers.js

    r206999 r207520  
    6666    return {
    6767        name: name,
     68        class: CustomElement,
    6869        takeLog: function () {
    6970            let currentLog = log; log = [];
Note: See TracChangeset for help on using the changeset viewer.