Changeset 230664 in webkit


Ignore:
Timestamp:
Apr 15, 2018 6:01:18 PM (6 years ago)
Author:
Chris Dumez
Message:

Change Event's returnValue so it doesn't expose a new primitive
https://bugs.webkit.org/show_bug.cgi?id=184415

Reviewed by Darin Adler.

LayoutTests/imported/w3c:

Import test coverage from https://github.com/w3c/web-platform-tests/pull/10258.

  • web-platform-tests/dom/events/AddEventListenerOptions-passive-expected.txt:
  • web-platform-tests/dom/events/AddEventListenerOptions-passive.html:
  • web-platform-tests/dom/events/Event-constructors.html:
  • web-platform-tests/dom/events/Event-defaultPrevented-after-dispatch-expected.txt:
  • web-platform-tests/dom/events/Event-defaultPrevented-after-dispatch.html:
  • web-platform-tests/dom/events/Event-defaultPrevented-expected.txt:
  • web-platform-tests/dom/events/Event-defaultPrevented.html:
  • web-platform-tests/dom/events/Event-dispatch-click.html:
  • web-platform-tests/dom/events/Event-dispatch-detached-click.html:
  • web-platform-tests/dom/events/Event-dispatch-other-document.html:
  • web-platform-tests/dom/events/Event-initEvent.html:
  • web-platform-tests/dom/events/Event-returnValue-expected.txt: Added.
  • web-platform-tests/dom/events/Event-returnValue.html: Added.
  • web-platform-tests/dom/events/EventListener-handleEvent.html:
  • web-platform-tests/dom/events/EventTarget-dispatchEvent-returnvalue-expected.txt:
  • web-platform-tests/dom/events/EventTarget-dispatchEvent-returnvalue.html:
  • web-platform-tests/dom/events/w3c-import.log:
  • web-platform-tests/dom/interfaces-expected.txt:
  • web-platform-tests/interfaces/dom.idl:

Source/WebCore:

Update Event.returnValue setter to match the latest DOM specification after:

In particular, the returnValue setter is now a no-op if the new flag value
is true. If the input flag value is false, it only sets the 'canceled' flag
if the event is cancelable and the event’s in passive listener flag is unset.

Test: imported/w3c/web-platform-tests/dom/events/Event-returnValue.html

  • dom/Event.cpp:

(WebCore::Event::setLegacyReturnValue):
(WebCore::Event::setCanceledFlagIfPossible):
(WebCore::Event::preventDefault):

  • dom/Event.h:
Location:
trunk
Files:
2 added
21 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r230632 r230664  
     12018-04-15  Chris Dumez  <cdumez@apple.com>
     2
     3        Change Event's returnValue so it doesn't expose a new primitive
     4        https://bugs.webkit.org/show_bug.cgi?id=184415
     5
     6        Reviewed by Darin Adler.
     7
     8        Import test coverage from https://github.com/w3c/web-platform-tests/pull/10258.
     9
     10        * web-platform-tests/dom/events/AddEventListenerOptions-passive-expected.txt:
     11        * web-platform-tests/dom/events/AddEventListenerOptions-passive.html:
     12        * web-platform-tests/dom/events/Event-constructors.html:
     13        * web-platform-tests/dom/events/Event-defaultPrevented-after-dispatch-expected.txt:
     14        * web-platform-tests/dom/events/Event-defaultPrevented-after-dispatch.html:
     15        * web-platform-tests/dom/events/Event-defaultPrevented-expected.txt:
     16        * web-platform-tests/dom/events/Event-defaultPrevented.html:
     17        * web-platform-tests/dom/events/Event-dispatch-click.html:
     18        * web-platform-tests/dom/events/Event-dispatch-detached-click.html:
     19        * web-platform-tests/dom/events/Event-dispatch-other-document.html:
     20        * web-platform-tests/dom/events/Event-initEvent.html:
     21        * web-platform-tests/dom/events/Event-returnValue-expected.txt: Added.
     22        * web-platform-tests/dom/events/Event-returnValue.html: Added.
     23        * web-platform-tests/dom/events/EventListener-handleEvent.html:
     24        * web-platform-tests/dom/events/EventTarget-dispatchEvent-returnvalue-expected.txt:
     25        * web-platform-tests/dom/events/EventTarget-dispatchEvent-returnvalue.html:
     26        * web-platform-tests/dom/events/w3c-import.log:
     27        * web-platform-tests/dom/interfaces-expected.txt:
     28        * web-platform-tests/interfaces/dom.idl:
     29
    1302018-04-12  Antoine Quint  <graouts@apple.com>
    231
  • trunk/LayoutTests/imported/w3c/web-platform-tests/IndexedDB/interfaces.any.worker-expected.txt

    r230285 r230664  
    2121PASS ProcessingInstruction interface: existence and properties of interface object
    2222PASS Comment interface: existence and properties of interface object
     23PASS AbstractRange interface: existence and properties of interface object
     24PASS StaticRange interface: existence and properties of interface object
    2325PASS Range interface: existence and properties of interface object
    2426PASS NodeIterator interface: existence and properties of interface object
  • trunk/LayoutTests/imported/w3c/web-platform-tests/dom/events/AddEventListenerOptions-passive-expected.txt

    r201826 r230664  
    22PASS Supports passive option on addEventListener only
    33PASS preventDefault should be ignored if-and-only-if the passive option is true
    4 PASS passive behavior of one listener should be unaffeted by the presence of other listeners
     4PASS returnValue should be ignored if-and-only-if the passive option is true
     5PASS passive behavior of one listener should be unaffected by the presence of other listeners
    56PASS Equivalence of option values
    67
  • trunk/LayoutTests/imported/w3c/web-platform-tests/dom/events/AddEventListenerOptions-passive.html

    r217225 r230664  
    5656}, "preventDefault should be ignored if-and-only-if the passive option is true");
    5757
     58function testPassiveValueOnReturnValue(test, optionsValue, expectedDefaultPrevented) {
     59  var defaultPrevented = undefined;
     60  var handler = test.step_func(e => {
     61    assert_false(e.defaultPrevented, "Event prematurely marked defaultPrevented");
     62    e.returnValue = false;
     63    defaultPrevented = e.defaultPrevented;
     64  });
     65  document.addEventListener('test', handler, optionsValue);
     66  var uncanceled = document.body.dispatchEvent(new Event('test', {bubbles: true, cancelable: true}));
     67
     68  assert_equals(defaultPrevented, expectedDefaultPrevented, "Incorrect defaultPrevented for options: " + JSON.stringify(optionsValue));
     69  assert_equals(uncanceled, !expectedDefaultPrevented, "Incorrect return value from dispatchEvent");
     70
     71  document.removeEventListener('test', handler, optionsValue);
     72}
     73
     74async_test(t => {
     75  testPassiveValueOnReturnValue(t, undefined, true);
     76  testPassiveValueOnReturnValue(t, {}, true);
     77  testPassiveValueOnReturnValue(t, {passive: false}, true);
     78  testPassiveValueOnReturnValue(t, {passive: true}, false);
     79  testPassiveValueOnReturnValue(t, {passive: 0}, true);
     80  testPassiveValueOnReturnValue(t, {passive: 1}, false);
     81  t.done();
     82}, "returnValue should be ignored if-and-only-if the passive option is true");
     83
    5884function testPassiveWithOtherHandlers(optionsValue, expectedDefaultPrevented) {
    5985  var handlerInvoked1 = false;
     
    82108  testPassiveWithOtherHandlers({passive: false}, true);
    83109  testPassiveWithOtherHandlers({passive: true}, false);
    84 }, "passive behavior of one listener should be unaffeted by the presence of other listeners");
     110}, "passive behavior of one listener should be unaffected by the presence of other listeners");
    85111
    86112function testOptionEquivalence(optionValue1, optionValue2, expectedEquality) {
  • trunk/LayoutTests/imported/w3c/web-platform-tests/dom/events/Event-constructors.html

    r217225 r230664  
    2020  assert_equals(ev.type, "")
    2121  assert_equals(ev.target, null)
     22  assert_equals(ev.srcElement, null)
    2223  assert_equals(ev.currentTarget, null)
    2324  assert_equals(ev.eventPhase, Event.NONE)
     
    2526  assert_equals(ev.cancelable, false)
    2627  assert_equals(ev.defaultPrevented, false)
     28  assert_equals(ev.returnValue, true)
    2729  assert_equals(ev.isTrusted, false)
    2830  assert_true(ev.timeStamp > 0)
     
    3335  assert_equals(ev.type, "test")
    3436  assert_equals(ev.target, null)
     37  assert_equals(ev.srcElement, null)
    3538  assert_equals(ev.currentTarget, null)
    3639  assert_equals(ev.eventPhase, Event.NONE)
     
    3841  assert_equals(ev.cancelable, false)
    3942  assert_equals(ev.defaultPrevented, false)
     43  assert_equals(ev.returnValue, true)
    4044  assert_equals(ev.isTrusted, false)
    4145  assert_true(ev.timeStamp > 0)
  • trunk/LayoutTests/imported/w3c/web-platform-tests/dom/events/Event-defaultPrevented-after-dispatch-expected.txt

    r200309 r230664  
    11
    2 PASS Event.defaultPrevented is not reset after dipatchEvent()
     2PASS Default prevention via preventDefault
     3PASS Default prevention via returnValue
    34
  • trunk/LayoutTests/imported/w3c/web-platform-tests/dom/events/Event-defaultPrevented-after-dispatch.html

    r217225 r230664  
    11<!DOCTYPE html>
    22<meta charset=utf-8>
    3 <title>Event.defaultPrevented is not reset after dipatchEvent()</title>
     3<title>Event.defaultPrevented is not reset after dispatchEvent()</title>
    44<script src="/resources/testharness.js"></script>
    55<script src="/resources/testharnessreport.js"></script>
     
    2323    assert_true(evt.defaultPrevented, "after dispatch");
    2424    assert_equals(evt.target, TARGET);
    25 });
     25    assert_equals(evt.srcElement, TARGET);
     26}, "Default prevention via preventDefault");
     27
     28test(function() {
     29    var EVENT = "foo";
     30    var TARGET = document.getElementById("target");
     31    var evt = document.createEvent("Event");
     32    evt.initEvent(EVENT, true, true);
     33
     34    TARGET.addEventListener(EVENT, this.step_func(function(e) {
     35        e.returnValue = false;
     36        assert_true(e.defaultPrevented, "during dispatch");
     37    }), true);
     38    TARGET.dispatchEvent(evt);
     39
     40    assert_true(evt.defaultPrevented, "after dispatch");
     41    assert_equals(evt.target, TARGET);
     42    assert_equals(evt.srcElement, TARGET);
     43}, "Default prevention via returnValue");
    2644</script>
  • trunk/LayoutTests/imported/w3c/web-platform-tests/dom/events/Event-defaultPrevented-expected.txt

    r202471 r230664  
    33PASS initEvent should work correctly (not cancelable).
    44PASS preventDefault() should not change defaultPrevented if cancelable is false.
     5PASS returnValue should not change defaultPrevented if cancelable is false.
    56PASS initEvent should work correctly (cancelable).
    67PASS preventDefault() should change defaultPrevented if cancelable is true.
     8PASS returnValue should change defaultPrevented if cancelable is true.
    79PASS initEvent should unset defaultPrevented.
    810
  • trunk/LayoutTests/imported/w3c/web-platform-tests/dom/events/Event-defaultPrevented.html

    r217225 r230664  
    2323}, "preventDefault() should not change defaultPrevented if cancelable is false.");
    2424test(function() {
     25  assert_equals(ev.cancelable, false, "cancelable (before)");
     26  ev.returnValue = false;
     27  assert_equals(ev.cancelable, false, "cancelable (after)");
     28  assert_equals(ev.defaultPrevented, false, "defaultPrevented");
     29}, "returnValue should not change defaultPrevented if cancelable is false.");
     30test(function() {
    2531  ev.initEvent("foo", true, true);
    2632  assert_equals(ev.bubbles, true, "bubbles");
     
    3541}, "preventDefault() should change defaultPrevented if cancelable is true.");
    3642test(function() {
     43  assert_equals(ev.cancelable, true, "cancelable (before)");
     44  ev.returnValue = false;
     45  assert_equals(ev.cancelable, true, "cancelable (after)");
     46  assert_equals(ev.defaultPrevented, true, "defaultPrevented");
     47}, "returnValue should change defaultPrevented if cancelable is true.");
     48test(function() {
    3749  ev.initEvent("foo", true, true);
    3850  assert_equals(ev.bubbles, true, "bubbles");
  • trunk/LayoutTests/imported/w3c/web-platform-tests/dom/events/Event-dispatch-click.html

    r220772 r230664  
    9595  input.onchange = t.step_func_done(function() {
    9696    assert_false(clickEvent.defaultPrevented)
     97    assert_true(clickEvent.returnValue)
    9798    assert_equals(clickEvent.eventPhase, 0)
    9899    assert_equals(clickEvent.currentTarget, null)
    99100    assert_equals(clickEvent.target, input)
     101    assert_equals(clickEvent.srcElement, input)
    100102    assert_equals(clickEvent.composedPath().length, 0)
    101103  })
     
    111113  finalTarget.onclick = t.step_func_done(function() {
    112114    assert_equals(clickEvent.target, finalTarget)
     115    assert_equals(clickEvent.srcElement, finalTarget)
    113116  })
    114117  input.onchange = t.step_func(function() {
  • trunk/LayoutTests/imported/w3c/web-platform-tests/dom/events/Event-dispatch-detached-click.html

    r217225 r230664  
    1111  TARGET.addEventListener(EVENT, t.step_func(function(evt) {
    1212    assert_equals(evt.target, TARGET);
     13    assert_equals(evt.srcElement, TARGET);
    1314    t.done();
    1415  }), true);
  • trunk/LayoutTests/imported/w3c/web-platform-tests/dom/events/Event-dispatch-other-document.html

    r217225 r230664  
    1313    called = true;
    1414    assert_equals(ev.target, element);
     15    assert_equals(ev.srcElement, element);
    1516  }));
    1617  doc.body.appendChild(element);
  • trunk/LayoutTests/imported/w3c/web-platform-tests/dom/events/Event-initEvent.html

    r217225 r230664  
    1313      e.initEvent("type", bubbles, cancelable)
    1414
    15       // Step 3.
     15      // Step 2.
    1616      // Stop (immediate) propagation flag is tested later
    1717      assert_equals(e.defaultPrevented, false, "defaultPrevented")
     18      assert_equals(e.returnValue, true, "returnValue")
     19      // Step 3.
     20      assert_equals(e.isTrusted, false, "isTrusted")
    1821      // Step 4.
    19       assert_equals(e.isTrusted, false, "isTrusted")
     22      assert_equals(e.target, null, "target")
     23      assert_equals(e.srcElement, null, "srcElement")
    2024      // Step 5.
    21       assert_equals(e.target, null, "target")
     25      assert_equals(e.type, "type", "type")
    2226      // Step 6.
    23       assert_equals(e.type, "type", "type")
     27      assert_equals(e.bubbles, bubbles, "bubbles")
    2428      // Step 7.
    25       assert_equals(e.bubbles, bubbles, "bubbles")
    26       // Step 8.
    2729      assert_equals(e.cancelable, cancelable, "cancelable")
    2830    }, "Properties of initEvent(type, " + bubbles + ", " + cancelable + ")")
  • trunk/LayoutTests/imported/w3c/web-platform-tests/dom/events/EventListener-handleEvent.html

    r217225 r230664  
    2828                assert_equals(evt.type, event);
    2929                assert_equals(evt.target, target);
     30                assert_equals(evt.srcElement, target);
    3031                assert_equals(that, event_listener);
    3132            });
  • trunk/LayoutTests/imported/w3c/web-platform-tests/dom/events/EventTarget-dispatchEvent-returnvalue-expected.txt

    r189471 r230664  
    11
    2 PASS Return value of EventTarget.dispatchEvent.
     2PASS Return value of EventTarget.dispatchEvent() affected by preventDefault().
     3PASS Return value of EventTarget.dispatchEvent() affected by returnValue.
    34
  • trunk/LayoutTests/imported/w3c/web-platform-tests/dom/events/EventTarget-dispatchEvent-returnvalue.html

    r217225 r230664  
    44<link rel="help" href="https://dom.spec.whatwg.org/#concept-event-dispatch">
    55<link rel="help" href="https://dom.spec.whatwg.org/#dom-event-preventdefault">
     6<link rel="help" href="https://dom.spec.whatwg.org/#dom-event-returnvalue">
    67<link rel="help" href="https://dom.spec.whatwg.org/#dom-event-defaultprevented">
    78<script src="/resources/testharness.js"></script>
     
    2627    var parent = document.getElementById("parent");
    2728    var default_prevented;
     29    var return_value;
    2830
    2931    parent.addEventListener(event_type, function(e) {}, true);
     
    3133        evt.preventDefault();
    3234        default_prevented = evt.defaultPrevented;
     35        return_value = evt.returnValue;
    3336    }, true);
    3437    target.addEventListener(event_type, function(e) {}, true);
     
    4043    assert_false(target.dispatchEvent(evt));
    4144    assert_true(default_prevented);
    42 }, "Return value of EventTarget.dispatchEvent.");
     45    assert_false(return_value);
     46}, "Return value of EventTarget.dispatchEvent() affected by preventDefault().");
     47
     48test(function() {
     49    var event_type = "foo";
     50    var target = document.getElementById("target");
     51    var parent = document.getElementById("parent");
     52    var default_prevented;
     53    var return_value;
     54
     55    parent.addEventListener(event_type, function(e) {}, true);
     56    target.addEventListener(event_type, function(e) {
     57        evt.returnValue = false;
     58        default_prevented = evt.defaultPrevented;
     59        return_value = evt.returnValue;
     60    }, true);
     61    target.addEventListener(event_type, function(e) {}, true);
     62
     63    var evt = document.createEvent("Event");
     64    evt.initEvent(event_type, true, true);
     65
     66    assert_true(parent.dispatchEvent(evt));
     67    assert_false(target.dispatchEvent(evt));
     68    assert_true(default_prevented);
     69    assert_false(return_value);
     70}, "Return value of EventTarget.dispatchEvent() affected by returnValue.");
    4371</script>
  • trunk/LayoutTests/imported/w3c/web-platform-tests/dom/events/w3c-import.log

    r229544 r230664  
    4343/LayoutTests/imported/w3c/web-platform-tests/dom/events/Event-initEvent.html
    4444/LayoutTests/imported/w3c/web-platform-tests/dom/events/Event-propagation.html
     45/LayoutTests/imported/w3c/web-platform-tests/dom/events/Event-returnValue.html
    4546/LayoutTests/imported/w3c/web-platform-tests/dom/events/Event-subclasses-constructors.html
    4647/LayoutTests/imported/w3c/web-platform-tests/dom/events/Event-timestamp-high-resolution.html
  • trunk/LayoutTests/imported/w3c/web-platform-tests/dom/interfaces-expected.txt

    r230285 r230664  
    2525PASS Event interface: attribute target
    2626PASS Unscopable handled correctly for target property on Event
     27PASS Event interface: attribute srcElement
     28PASS Unscopable handled correctly for srcElement property on Event
    2729PASS Event interface: attribute currentTarget
    2830PASS Unscopable handled correctly for currentTarget property on Event
     
    4547PASS Event interface: attribute cancelable
    4648PASS Unscopable handled correctly for cancelable property on Event
     49PASS Event interface: attribute returnValue
     50PASS Unscopable handled correctly for returnValue property on Event
    4751PASS Event interface: operation preventDefault()
    4852PASS Unscopable handled correctly for preventDefault() on Event
     
    5761PASS Event interface: document.createEvent("Event") must inherit property "type" with the proper type
    5862PASS Event interface: document.createEvent("Event") must inherit property "target" with the proper type
     63PASS Event interface: document.createEvent("Event") must inherit property "srcElement" with the proper type
    5964PASS Event interface: document.createEvent("Event") must inherit property "currentTarget" with the proper type
    6065PASS Event interface: document.createEvent("Event") must inherit property "NONE" with the proper type
     
    6772PASS Event interface: document.createEvent("Event") must inherit property "bubbles" with the proper type
    6873PASS Event interface: document.createEvent("Event") must inherit property "cancelable" with the proper type
     74PASS Event interface: document.createEvent("Event") must inherit property "returnValue" with the proper type
    6975PASS Event interface: document.createEvent("Event") must inherit property "preventDefault()" with the proper type
    7076PASS Event interface: document.createEvent("Event") must inherit property "defaultPrevented" with the proper type
     
    7783PASS Event interface: new Event("foo") must inherit property "type" with the proper type
    7884PASS Event interface: new Event("foo") must inherit property "target" with the proper type
     85PASS Event interface: new Event("foo") must inherit property "srcElement" with the proper type
    7986PASS Event interface: new Event("foo") must inherit property "currentTarget" with the proper type
    8087PASS Event interface: new Event("foo") must inherit property "NONE" with the proper type
     
    8794PASS Event interface: new Event("foo") must inherit property "bubbles" with the proper type
    8895PASS Event interface: new Event("foo") must inherit property "cancelable" with the proper type
     96PASS Event interface: new Event("foo") must inherit property "returnValue" with the proper type
    8997PASS Event interface: new Event("foo") must inherit property "preventDefault()" with the proper type
    9098PASS Event interface: new Event("foo") must inherit property "defaultPrevented" with the proper type
     
    110118PASS Event interface: new CustomEvent("foo") must inherit property "type" with the proper type
    111119PASS Event interface: new CustomEvent("foo") must inherit property "target" with the proper type
     120PASS Event interface: new CustomEvent("foo") must inherit property "srcElement" with the proper type
    112121PASS Event interface: new CustomEvent("foo") must inherit property "currentTarget" with the proper type
    113122PASS Event interface: new CustomEvent("foo") must inherit property "NONE" with the proper type
     
    120129PASS Event interface: new CustomEvent("foo") must inherit property "bubbles" with the proper type
    121130PASS Event interface: new CustomEvent("foo") must inherit property "cancelable" with the proper type
     131PASS Event interface: new CustomEvent("foo") must inherit property "returnValue" with the proper type
    122132PASS Event interface: new CustomEvent("foo") must inherit property "preventDefault()" with the proper type
    123133PASS Event interface: new CustomEvent("foo") must inherit property "defaultPrevented" with the proper type
     
    16381648PASS EventTarget interface: document.createComment("abc") must inherit property "dispatchEvent(Event)" with the proper type
    16391649PASS EventTarget interface: calling dispatchEvent(Event) on document.createComment("abc") with too few arguments must throw TypeError
    1640 PASS Range interface: existence and properties of interface object
     1650FAIL AbstractRange interface: existence and properties of interface object assert_own_property: self does not have own property "AbstractRange" expected property "AbstractRange" missing
     1651FAIL AbstractRange interface object length assert_own_property: self does not have own property "AbstractRange" expected property "AbstractRange" missing
     1652FAIL AbstractRange interface object name assert_own_property: self does not have own property "AbstractRange" expected property "AbstractRange" missing
     1653FAIL AbstractRange interface: existence and properties of interface prototype object assert_own_property: self does not have own property "AbstractRange" expected property "AbstractRange" missing
     1654FAIL AbstractRange interface: existence and properties of interface prototype object's "constructor" property assert_own_property: self does not have own property "AbstractRange" expected property "AbstractRange" missing
     1655FAIL AbstractRange interface: existence and properties of interface prototype object's @@unscopables property assert_own_property: self does not have own property "AbstractRange" expected property "AbstractRange" missing
     1656FAIL AbstractRange interface: attribute startContainer assert_own_property: self does not have own property "AbstractRange" expected property "AbstractRange" missing
     1657PASS Unscopable handled correctly for startContainer property on AbstractRange
     1658FAIL AbstractRange interface: attribute startOffset assert_own_property: self does not have own property "AbstractRange" expected property "AbstractRange" missing
     1659PASS Unscopable handled correctly for startOffset property on AbstractRange
     1660FAIL AbstractRange interface: attribute endContainer assert_own_property: self does not have own property "AbstractRange" expected property "AbstractRange" missing
     1661PASS Unscopable handled correctly for endContainer property on AbstractRange
     1662FAIL AbstractRange interface: attribute endOffset assert_own_property: self does not have own property "AbstractRange" expected property "AbstractRange" missing
     1663PASS Unscopable handled correctly for endOffset property on AbstractRange
     1664FAIL AbstractRange interface: attribute collapsed assert_own_property: self does not have own property "AbstractRange" expected property "AbstractRange" missing
     1665PASS Unscopable handled correctly for collapsed property on AbstractRange
     1666FAIL StaticRange interface: existence and properties of interface object assert_own_property: should inherit from AbstractRange, but self has no such property expected property "AbstractRange" missing
     1667PASS StaticRange interface object length
     1668PASS StaticRange interface object name
     1669FAIL StaticRange interface: existence and properties of interface prototype object assert_own_property: should inherit from AbstractRange, but self has no such property expected property "AbstractRange" missing
     1670PASS StaticRange interface: existence and properties of interface prototype object's "constructor" property
     1671PASS StaticRange interface: existence and properties of interface prototype object's @@unscopables property
     1672FAIL Range interface: existence and properties of interface object assert_own_property: should inherit from AbstractRange, but self has no such property expected property "AbstractRange" missing
    16411673PASS Range interface object length
    16421674PASS Range interface object name
    1643 PASS Range interface: existence and properties of interface prototype object
     1675FAIL Range interface: existence and properties of interface prototype object assert_own_property: should inherit from AbstractRange, but self has no such property expected property "AbstractRange" missing
    16441676PASS Range interface: existence and properties of interface prototype object's "constructor" property
    16451677PASS Range interface: existence and properties of interface prototype object's @@unscopables property
    1646 PASS Range interface: attribute startContainer
    1647 PASS Unscopable handled correctly for startContainer property on Range
    1648 PASS Range interface: attribute startOffset
    1649 PASS Unscopable handled correctly for startOffset property on Range
    1650 PASS Range interface: attribute endContainer
    1651 PASS Unscopable handled correctly for endContainer property on Range
    1652 PASS Range interface: attribute endOffset
    1653 PASS Unscopable handled correctly for endOffset property on Range
    1654 PASS Range interface: attribute collapsed
    1655 PASS Unscopable handled correctly for collapsed property on Range
    16561678PASS Range interface: attribute commonAncestorContainer
    16571679PASS Unscopable handled correctly for commonAncestorContainer property on Range
     
    17071729PASS Range must be primary interface of document.createRange()
    17081730PASS Stringification of document.createRange()
    1709 PASS Range interface: document.createRange() must inherit property "startContainer" with the proper type
    1710 PASS Range interface: document.createRange() must inherit property "startOffset" with the proper type
    1711 PASS Range interface: document.createRange() must inherit property "endContainer" with the proper type
    1712 PASS Range interface: document.createRange() must inherit property "endOffset" with the proper type
    1713 PASS Range interface: document.createRange() must inherit property "collapsed" with the proper type
    17141731PASS Range interface: document.createRange() must inherit property "commonAncestorContainer" with the proper type
    17151732PASS Range interface: document.createRange() must inherit property "setStart(Node, unsigned long)" with the proper type
     
    17521769PASS Range interface: document.createRange() must inherit property "intersectsNode(Node)" with the proper type
    17531770PASS Range interface: calling intersectsNode(Node) on document.createRange() with too few arguments must throw TypeError
     1771PASS AbstractRange interface: document.createRange() must inherit property "startContainer" with the proper type
     1772PASS AbstractRange interface: document.createRange() must inherit property "startOffset" with the proper type
     1773PASS AbstractRange interface: document.createRange() must inherit property "endContainer" with the proper type
     1774PASS AbstractRange interface: document.createRange() must inherit property "endOffset" with the proper type
     1775PASS AbstractRange interface: document.createRange() must inherit property "collapsed" with the proper type
    17541776PASS Range must be primary interface of detachedRange
    17551777PASS Stringification of detachedRange
    1756 PASS Range interface: detachedRange must inherit property "startContainer" with the proper type
    1757 PASS Range interface: detachedRange must inherit property "startOffset" with the proper type
    1758 PASS Range interface: detachedRange must inherit property "endContainer" with the proper type
    1759 PASS Range interface: detachedRange must inherit property "endOffset" with the proper type
    1760 PASS Range interface: detachedRange must inherit property "collapsed" with the proper type
    17611778PASS Range interface: detachedRange must inherit property "commonAncestorContainer" with the proper type
    17621779PASS Range interface: detachedRange must inherit property "setStart(Node, unsigned long)" with the proper type
     
    17991816PASS Range interface: detachedRange must inherit property "intersectsNode(Node)" with the proper type
    18001817PASS Range interface: calling intersectsNode(Node) on detachedRange with too few arguments must throw TypeError
     1818PASS AbstractRange interface: detachedRange must inherit property "startContainer" with the proper type
     1819PASS AbstractRange interface: detachedRange must inherit property "startOffset" with the proper type
     1820PASS AbstractRange interface: detachedRange must inherit property "endContainer" with the proper type
     1821PASS AbstractRange interface: detachedRange must inherit property "endOffset" with the proper type
     1822PASS AbstractRange interface: detachedRange must inherit property "collapsed" with the proper type
    18011823PASS NodeIterator interface: existence and properties of interface object
    18021824PASS NodeIterator interface object length
  • trunk/LayoutTests/imported/w3c/web-platform-tests/interfaces/dom.idl

    r229544 r230664  
    44  readonly attribute DOMString type;
    55  readonly attribute EventTarget? target;
     6  readonly attribute EventTarget? srcElement;
    67  readonly attribute EventTarget? currentTarget;
    78
     
    1718  readonly attribute boolean bubbles;
    1819  readonly attribute boolean cancelable;
     20           attribute boolean returnValue;
    1921  void preventDefault();
    2022  readonly attribute boolean defaultPrevented;
     
    441443
    442444
    443 [Constructor,
    444  Exposed=Window]
    445 interface Range {
     445[Exposed=Window]
     446interface AbstractRange {
    446447  readonly attribute Node startContainer;
    447448  readonly attribute unsigned long startOffset;
     
    449450  readonly attribute unsigned long endOffset;
    450451  readonly attribute boolean collapsed;
     452};
     453
     454[Exposed=Window]
     455interface StaticRange : AbstractRange {
     456};
     457
     458[Constructor,
     459 Exposed=Window]
     460interface Range : AbstractRange {
    451461  readonly attribute Node commonAncestorContainer;
    452462
  • trunk/Source/WebCore/ChangeLog

    r230658 r230664  
     12018-04-15  Chris Dumez  <cdumez@apple.com>
     2
     3        Change Event's returnValue so it doesn't expose a new primitive
     4        https://bugs.webkit.org/show_bug.cgi?id=184415
     5
     6        Reviewed by Darin Adler.
     7
     8        Update Event.returnValue setter to match the latest DOM specification after:
     9        - https://github.com/whatwg/dom/pull/626
     10
     11        In particular, the returnValue setter is now a no-op if the new flag value
     12        is true. If the input flag value is false, it only sets the 'canceled' flag
     13        if the event is cancelable and the event’s in passive listener flag is unset.
     14
     15        Test: imported/w3c/web-platform-tests/dom/events/Event-returnValue.html
     16
     17        * dom/Event.cpp:
     18        (WebCore::Event::setLegacyReturnValue):
     19        (WebCore::Event::setCanceledFlagIfPossible):
     20        (WebCore::Event::preventDefault):
     21        * dom/Event.h:
     22
    1232018-04-14  Thibault Saunier  <tsaunier@igalia.com>
    224
  • trunk/Source/WebCore/dom/Event.h

    r228260 r230664  
    9797
    9898    bool legacyReturnValue() const { return !m_wasCanceled; }
    99     void setLegacyReturnValue(bool returnValue) { m_wasCanceled = !returnValue; }
     99    void setLegacyReturnValue(bool);
    100100
    101101    virtual EventInterface eventInterface() const { return EventInterfaceType; }
     
    154154    AtomicString m_type;
    155155
     156    void setCanceledFlagIfPossible();
     157
    156158    bool m_isInitialized { false };
    157159    bool m_canBubble { false };
     
    177179inline void Event::preventDefault()
    178180{
     181    setCanceledFlagIfPossible();
     182}
     183
     184inline void Event::setLegacyReturnValue(bool returnValue)
     185{
     186    if (!returnValue)
     187        setCanceledFlagIfPossible();
     188}
     189
     190// https://dom.spec.whatwg.org/#set-the-canceled-flag
     191inline void Event::setCanceledFlagIfPossible()
     192{
    179193    if (m_cancelable && !m_isExecutingPassiveEventListener)
    180194        m_wasCanceled = true;
Note: See TracChangeset for help on using the changeset viewer.