Commit a0a90bdd authored by hayato's avatar hayato Committed by Commit bot

Rename Event.deepPath() to Event.composedPath()

We renamed Event.deepPath() to Event.composedPath().

Issue: https://github.com/whatwg/dom/issues/242
DOM Standard: https://dom.spec.whatwg.org/#dom-event-composedpath

For histograms,
TBR=isherman@chromium.org

BUG=531990

Review-Url: https://codereview.chromium.org/2014173002
Cr-Commit-Position: refs/heads/master@{#396799}
parent 197454b5
......@@ -529,6 +529,8 @@ crbug.com/505364 imported/wpt/shadow-dom/untriaged/user-interaction/focus-naviga
crbug.com/505364 imported/wpt/shadow-dom/untriaged/user-interaction/focus-navigation/test-004.html [ Failure ]
crbug.com/505364 imported/wpt/custom-elements/v0/instantiating/extensions-to-document-interface/create-element-interface-type-is-a-type-extension.html [ Failure ]
crbug.com/505364 imported/csswg-test/css-scoping-1/css-scoping-shadow-slot-display-override.html [ Failure ]
crbug.com/505364 imported/wpt/shadow-dom/untriaged/elements-and-dom-objects/extensions-to-event-interface/event-path-001.html [ Failure ]
crbug.com/505364 imported/wpt/shadow-dom/untriaged/events/event-dispatch/test-003.html [ Failure ]
crbug.com/517840 imported/wpt/webrtc/rtcpeerconnection/rtcpeerconnection-idl.html [ Failure Timeout ]
......
......@@ -46,8 +46,8 @@ SELECT : '16384'
bubbles : 'false'
cancelBubble : 'false'
cancelable : 'false'
composedPath : 'function composedPath() { [native code] }'
currentTarget : '[object XMLHttpRequest]'
deepPath : 'function deepPath() { [native code] }'
defaultPrevented : 'false'
eventPhase : '2'
initEvent : 'function initEvent() { [native code] }'
......
......@@ -150,8 +150,8 @@ interface Event
getter target
getter timeStamp
getter type
method composedPath
method constructor
method deepPath
method initEvent
method preventDefault
method stopImmediatePropagation
......
......@@ -7,12 +7,12 @@ test(() => {
const ev = new Event("sample");
var dispatched = false;
target.addEventListener("sample", (e) => {
assert_true(e.deepPath().length > 0);
assert_true(e.composedPath().length > 0);
dispatched = true;
});
assert_array_equals(ev.deepPath(), []);
assert_array_equals(ev.composedPath(), []);
target.dispatchEvent(ev);
assert_true(dispatched);
assert_array_equals(ev.deepPath(), []);
}, "Event.deepPath() should return an empty array before/after dispatching an event");
assert_array_equals(ev.composedPath(), []);
}, "Event.composedPath() should return an empty array before/after dispatching an event");
</script>
......@@ -6,8 +6,8 @@
img.onload = function(e) {
test(function() {
assert_array_equals(e.deepPath(), e.path);
}, "Event.deepPath() should be the same as Event.path.");
assert_array_equals(e.composedPath(), e.path);
}, "Event.composedPath() should be the same as Event.path.");
};
</script>
Event.deepPath() should include only unclosed nodes.
Event.composedPath() should include only unclosed nodes.
Dispaching a click event on #target_open, listening on #target_open.
PASS eventPath.length is 9
event.deepPath() for #target_open:
event.composedPath() for #target_open:
#target_open, #open_shadow_in_open_shadow, #inner_open, #open_shadow, #host_open, [object HTMLBodyElement], [object HTMLHtmlElement], [object HTMLDocument], [object Window], length: 9
Dispaching a click event on #target_closed, listening on #target_closed.
PASS eventPath.length is 9
event.deepPath() for #target_closed:
event.composedPath() for #target_closed:
#target_closed, #open_shadow_in_closed_shadow, #inner_closed, #closed_shadow, #host_closed, [object HTMLBodyElement], [object HTMLHtmlElement], [object HTMLDocument], [object Window], length: 9
Dispaching a click event on #target_open, listening on document.body.
PASS eventPath.length is 9
event.deepPath() for #target_open:
event.composedPath() for #target_open:
#target_open, #open_shadow_in_open_shadow, #inner_open, #open_shadow, #host_open, [object HTMLBodyElement], [object HTMLHtmlElement], [object HTMLDocument], [object Window], length: 9
Dispaching a click event on #target_closed, listening on document.body.
PASS eventPath.length is 5
event.deepPath() for #target_closed:
event.composedPath() for #target_closed:
#host_closed, [object HTMLBodyElement], [object HTMLHtmlElement], [object HTMLDocument], [object Window], length: 5
PASS successfullyParsed is true
......
......@@ -22,10 +22,10 @@ function prepareTree() {
}
function clickHandler(e) {
eventPath = e.deepPath();
eventPath = e.composedPath();
}
debug('Event.deepPath() should include only unclosed nodes.');
debug('Event.composedPath() should include only unclosed nodes.');
prepareTree();
......@@ -41,7 +41,7 @@ targetOpen.click();
// Expected: <span#target_open>, #open_shadow_in_open_shadow, <div#inner_open>,
// #open_shadow, <div#host_open>, <body>, <html>, #document, window
shouldBe('eventPath.length', '9');
debug("\nevent.deepPath() for #target_open:");
debug("\nevent.composedPath() for #target_open:");
debug(dumpNodeList(eventPath));
debug("\nDispaching a click event on #target_closed, listening on #target_closed.");
......@@ -50,7 +50,7 @@ targetClosed.click();
// Expected: <span#target_closed>, #open_shadow_in_closed_shadow, <div#inner_closed>,
// #closed_shadow, <div#host_closed>, <body>, <html>, #document, window
shouldBe('eventPath.length', '9');
debug("\nevent.deepPath() for #target_closed:");
debug("\nevent.composedPath() for #target_closed:");
debug(dumpNodeList(eventPath));
......@@ -64,7 +64,7 @@ targetOpen.click();
// Expected: <span#target_open>, #open_shadow_in_open_shadow, <div#inner_open>,
// #open_shadow, <div#host_open>, <body>, <html>, #document, window
shouldBe('eventPath.length', '9');
debug("\nevent.deepPath() for #target_open:");
debug("\nevent.composedPath() for #target_open:");
debug(dumpNodeList(eventPath));
debug("\nDispaching a click event on #target_closed, listening on document.body.");
......@@ -74,6 +74,6 @@ targetClosed.click();
// thus 9 - 4 = 5.
// Expected: <div#host_closed>, <body>, <html>, #document, window
shouldBe('eventPath.length', '5');
debug("\nevent.deepPath() for #target_closed:");
debug("\nevent.composedPath() for #target_closed:");
debug(dumpNodeList(eventPath));
</script>
Event.deepPath() should include only unclosed nodes.
Event.composedPath() should include only unclosed nodes.
The full event path should be (length=12):
div#target, #shadow-root (open), div#div3_open, #shadow-root (closed),
div#div2_closed, #shadow-root (open), div#host_open, div#host_closed,
......@@ -10,23 +10,23 @@ will be trimmed (length=8).
Dispaching a click event on #target, listening on #host_closed.
Got event.deepPath() for #host_closed:
Got event.composedPath() for #host_closed:
#div2_closed, [object ShadowRoot], #host_open, #host_closed, [object HTMLBodyElement], [object HTMLHtmlElement], [object HTMLDocument], [object Window], length: 8
Dispaching a click event on #target, listening on #host_open.
Got event.deepPath() for #host_open:
Got event.composedPath() for #host_open:
#div2_closed, [object ShadowRoot], #host_open, #host_closed, [object HTMLBodyElement], [object HTMLHtmlElement], [object HTMLDocument], [object Window], length: 8
Dispaching a click event on #target, listening on #div2_closed.
Got event.deepPath() for #div2_closed:
Got event.composedPath() for #div2_closed:
#div2_closed, [object ShadowRoot], #host_open, #host_closed, [object HTMLBodyElement], [object HTMLHtmlElement], [object HTMLDocument], [object Window], length: 8
Dispaching a click event on #target, listening on #div3_open.
Got event.deepPath() for #div3_open:
Got event.composedPath() for #div3_open:
#target, [object ShadowRoot], #div3_open, [object ShadowRoot], #div2_closed, [object ShadowRoot], #host_open, #host_closed, [object HTMLBodyElement], [object HTMLHtmlElement], [object HTMLDocument], [object Window], length: 12
Dispaching a click event on #target, listening on #target.
Got event.deepPath() for #target:
Got event.composedPath() for #target:
#target, [object ShadowRoot], #div3_open, [object ShadowRoot], #div2_closed, [object ShadowRoot], #host_open, #host_closed, [object HTMLBodyElement], [object HTMLHtmlElement], [object HTMLDocument], [object Window], length: 12
PASS successfullyParsed is true
......
......@@ -21,7 +21,7 @@ function prepareTree() {
createDOM('div', {id: 'target'})))))))));
}
debug('Event.deepPath() should include only unclosed nodes.');
debug('Event.composedPath() should include only unclosed nodes.');
prepareTree();
......@@ -40,13 +40,13 @@ debug('On #host_closed, #host_open, and #div2_closed,\n' +
var node = getNodeInComposedTree(nodePath);
var eventPath;
var clickHandler = function(e) { eventPath = e.deepPath(); };
var clickHandler = function(e) { eventPath = e.composedPath(); };
node.addEventListener('click', clickHandler, false);
debug('\nDispaching a click event on #target, listening on #' + node.id + '.');
eventPath = null;
target.click();
debug('Got event.deepPath() for #' + node.id + ':');
debug('Got event.composedPath() for #' + node.id + ':');
debug(dumpNodeList(eventPath));
node.removeEventListener('click', clickHandler, false);
......
......@@ -43,7 +43,7 @@ test(function() {
var shadowRoot = host1.shadowRoot;
input1.onfocus = function(e) {
var expected_array1 = [input1, slot1, shadowRoot, host1, document.body, document.documentElement, document, window];
assert_array_equals(e.deepPath(), expected_array1);
assert_array_equals(e.composedPath(), expected_array1);
};
input1.focus();
}, 'Triggered in a slotted element, eventPath should go through shadow tree.');
......@@ -62,7 +62,7 @@ test(function() {
input2.onfocus = function(e) {
var expected_array2 = [input2, slot2, slotParent, content, shadowRootV0, host3, shadowRootV1, host2, document.body, document.documentElement, document, window];
assert_array_equals(e.deepPath(), expected_array2);
assert_array_equals(e.composedPath(), expected_array2);
};
input2.focus();
}, 'EventPath works fine with v0 insertion points & v1 slots.');
......@@ -76,7 +76,7 @@ test(function() {
var inputParent = document.getElementById('input-parent');
input3.onfocus = function(e) {
var expected_array3 = [input3, inputParent, slot3, shadowRoot2, host4, document.body, document.documentElement, document, window];
assert_array_equals(e.deepPath(), expected_array3);
assert_array_equals(e.composedPath(), expected_array3);
};
input3.focus();
}, 'EventPath works fine when event happens to a descendant of a slotted element.');
......
......@@ -40,8 +40,8 @@ var host = getNodeInComposedTree('host');
async_test(function(t) {
target.onselect = function(e) {
t.step(function() {
assert_true(e.deepPath().includes(target));
assert_false(e.deepPath().includes(host));
assert_true(e.composedPath().includes(target));
assert_false(e.composedPath().includes(host));
t.done();
});
}
......@@ -50,8 +50,8 @@ async_test(function(t) {
async_test(function(t) {
target.onerror = function(e) {
t.step(function() {
assert_true(e.deepPath().includes(target));
assert_true(e.deepPath().includes(host));
assert_true(e.composedPath().includes(target));
assert_true(e.composedPath().includes(host));
t.done();
});
}
......
......@@ -170,8 +170,8 @@ Starting worker: resources/global-interface-listing.js
[Worker] getter target
[Worker] getter timeStamp
[Worker] getter type
[Worker] method composedPath
[Worker] method constructor
[Worker] method deepPath
[Worker] method initEvent
[Worker] method preventDefault
[Worker] method stopImmediatePropagation
......
......@@ -1589,8 +1589,8 @@ interface Event
getter target
getter timeStamp
getter type
method composedPath
method constructor
method deepPath
method initEvent
method preventDefault
method stopImmediatePropagation
......
......@@ -157,8 +157,8 @@ Starting worker: resources/global-interface-listing.js
[Worker] getter target
[Worker] getter timeStamp
[Worker] getter type
[Worker] method composedPath
[Worker] method constructor
[Worker] method deepPath
[Worker] method initEvent
[Worker] method preventDefault
[Worker] method stopImmediatePropagation
......
......@@ -281,7 +281,7 @@ HeapVector<Member<EventTarget>> Event::path(ScriptState* scriptState) const
return pathInternal(scriptState, NonEmptyAfterDispatch);
}
HeapVector<Member<EventTarget>> Event::deepPath(ScriptState* scriptState) const
HeapVector<Member<EventTarget>> Event::composedPath(ScriptState* scriptState) const
{
return pathInternal(scriptState, EmptyAfterDispatch);
}
......
......@@ -196,7 +196,7 @@ public:
void initEventPath(Node&);
HeapVector<Member<EventTarget>> path(ScriptState*) const;
HeapVector<Member<EventTarget>> deepPath(ScriptState*) const;
HeapVector<Member<EventTarget>> composedPath(ScriptState*) const;
bool isBeingDispatched() const { return eventPhase(); }
......
......@@ -66,7 +66,7 @@
// Shadow DOM
// https://w3c.github.io/webcomponents/spec/shadow/#extensions-to-event-interface
[MeasureAs=EventPath, CallWith=ScriptState] readonly attribute EventTarget[] path;
[RuntimeEnabled=ShadowDOMV1, MeasureAs=EventDeepPath, CallWith=ScriptState] sequence<EventTarget> deepPath();
[RuntimeEnabled=ShadowDOMV1, MeasureAs=EventComposedPath, CallWith=ScriptState] sequence<EventTarget> composedPath();
// Non-standard APIs
const unsigned short MOUSEDOWN = 1;
......
......@@ -935,7 +935,7 @@ public:
MediaDevicesEnumerateDevices = 1119,
NonSecureSharedWorkerAccessedFromSecureContext = 1120,
SecureSharedWorkerAccessedFromNonSecureContext = 1121,
EventDeepPath = 1123,
EventComposedPath = 1123,
LinkHeaderPreload = 1124,
MouseWheelEvent = 1125,
WheelEvent = 1126,
......
......@@ -73702,7 +73702,7 @@ http://cs/file:chrome/histograms.xml - but prefer this file for new entries.
<int value="1120" label="NonSecureSharedWorkerAccessedFromSecureContext"/>
<int value="1121" label="SecureSharedWorkerAccessedFromNonSecureContext"/>
<int value="1122" label="NonCSSStyleSheetType"/>
<int value="1123" label="EventDeepPath"/>
<int value="1123" label="EventComposedPath"/>
<int value="1124" label="LinkHeaderPreload"/>
<int value="1125" label="MouseWheelEvent"/>
<int value="1126" label="WheelEvent"/>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment