This repository has been archived by the owner on Jun 24, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Default passive touch event listeners on the root
https://bugs.webkit.org/show_bug.cgi?id=175346 <rdar://problem/33164597> Reviewed by Sam Weinig. Source/WebCore: Make any touchstart or touchmove event listeners passive by default if they are on the document, window, body or document element targets. This follows the "intervention" first implemented by Chrome/Blink: WICG/interventions#35 https://docs.google.com/document/d/1II7oSIpd8pK91V5kEM3tDLKcIj398jOJn8Niqy6_loI/edit whatwg/dom#365 If the event listener explicitly defines "passive" to false in their options dictionary, then they'll still get a non-passive listener. NOTE: Any fallout from this bug should be collected in: https://bugs.webkit.org/show_bug.cgi?id=175869 Please do not revert this change just because a site is broken. We'll gather the issues and see if we can evangelise or detect via code. Tests: fast/events/touch/ios/passive-by-default-on-document-and-window.html fast/events/touch/ios/passive-by-default-overridden-on-document-and-window.html * dom/EventNames.h: (WebCore::EventNames::isTouchScrollBlockingEventType const): Added this helper to identify the types of touches we want to check for. * dom/EventTarget.cpp: (WebCore::EventTarget::addEventListener): Check for the event being one of the touch-types that we care about, and the target being one of the Node/Window types we care about. If so, tell the event listener to be passive. * dom/EventTarget.h: Use an optional for the passive member. (WebCore::EventTarget::AddEventListenerOptions::AddEventListenerOptions): * dom/EventTarget.idl: Change "passive" to not have a default value, so we can detect if it was explicitly set to false. LayoutTests: * fast/events/touch/ios/passive-by-default-on-document-and-window-expected.txt: Added. * fast/events/touch/ios/passive-by-default-on-document-and-window.html: Added. * fast/events/touch/ios/passive-by-default-overridden-on-document-and-window-expected.txt: Added. * fast/events/touch/ios/passive-by-default-overridden-on-document-and-window.html: Added. * fast/events/touch/ios/tap-with-active-listener-on-window.html: Explicitly set passive to false. * fast/events/touch/ios/touch-event-regions/document.html: Ditto. git-svn-id: http://svn.webkit.org/repository/webkit/trunk@221092 268f45cc-cd09-0410-ab3c-d52691b4dbfc
- Loading branch information
dino@apple.com
committed
Aug 23, 2017
1 parent
adc7028
commit 9c8039a
Showing
12 changed files
with
299 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
LayoutTests/fast/events/touch/ios/passive-by-default-on-document-and-window-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
touchstart on body - cancelable: false defaultPrevented: false | ||
touchstart on documentElement - cancelable: false defaultPrevented: false | ||
touchstart on document - cancelable: false defaultPrevented: false | ||
touchstart on window - cancelable: false defaultPrevented: false | ||
touchmove on body - cancelable: false defaultPrevented: false | ||
touchmove on documentElement - cancelable: false defaultPrevented: false | ||
touchmove on document - cancelable: false defaultPrevented: false | ||
touchmove on window - cancelable: false defaultPrevented: false | ||
touchend on body - cancelable: false defaultPrevented: false | ||
touchend on documentElement - cancelable: false defaultPrevented: false | ||
touchend on document - cancelable: false defaultPrevented: false | ||
touchend on window - cancelable: false defaultPrevented: false | ||
Done |
97 changes: 97 additions & 0 deletions
97
LayoutTests/fast/events/touch/ios/passive-by-default-on-document-and-window.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
<script> | ||
if (window.testRunner) { | ||
testRunner.dumpAsText(); | ||
testRunner.waitUntilDone(); | ||
} | ||
|
||
function getUIScript() | ||
{ | ||
return ` | ||
(function() { | ||
uiController.dragFromPointToPoint(50, 250, 50, 30, 0.1, function() { | ||
uiController.uiScriptComplete("Done"); | ||
}); | ||
})();` | ||
} | ||
|
||
function runTest() | ||
{ | ||
let output = ""; | ||
window.addEventListener("touchstart", function(event) { | ||
event.preventDefault(); | ||
output += `touchstart on window - cancelable: ${event.cancelable} defaultPrevented: ${event.defaultPrevented} <br>`; | ||
}, false); | ||
|
||
window.addEventListener("touchmove", function(event) { | ||
event.preventDefault(); | ||
output += `touchmove on window - cancelable: ${event.cancelable} defaultPrevented: ${event.defaultPrevented} <br>`; | ||
}, false); | ||
|
||
window.addEventListener("touchend", function(event) { | ||
event.preventDefault(); | ||
output += `touchend on window - cancelable: ${event.cancelable} defaultPrevented: ${event.defaultPrevented} <br>`; | ||
}, false); | ||
|
||
document.addEventListener("touchstart", function(event) { | ||
event.preventDefault(); | ||
output += `touchstart on document - cancelable: ${event.cancelable} defaultPrevented: ${event.defaultPrevented} <br>`; | ||
}, false); | ||
|
||
document.addEventListener("touchmove", function(event) { | ||
event.preventDefault(); | ||
output += `touchmove on document - cancelable: ${event.cancelable} defaultPrevented: ${event.defaultPrevented} <br>`; | ||
}, false); | ||
|
||
document.addEventListener("touchend", function(event) { | ||
event.preventDefault(); | ||
output += `touchend on document - cancelable: ${event.cancelable} defaultPrevented: ${event.defaultPrevented} <br>`; | ||
}, false); | ||
|
||
document.documentElement.addEventListener("touchstart", function(event) { | ||
event.preventDefault(); | ||
output += `touchstart on documentElement - cancelable: ${event.cancelable} defaultPrevented: ${event.defaultPrevented} <br>`; | ||
}, false); | ||
|
||
document.documentElement.addEventListener("touchmove", function(event) { | ||
event.preventDefault(); | ||
output += `touchmove on documentElement - cancelable: ${event.cancelable} defaultPrevented: ${event.defaultPrevented} <br>`; | ||
}, false); | ||
|
||
document.documentElement.addEventListener("touchend", function(event) { | ||
event.preventDefault(); | ||
output += `touchend on documentElement - cancelable: ${event.cancelable} defaultPrevented: ${event.defaultPrevented} <br>`; | ||
}, false); | ||
|
||
let body = document.querySelector("body"); | ||
|
||
body.addEventListener("touchstart", function(event) { | ||
event.preventDefault(); | ||
output += `touchstart on body - cancelable: ${event.cancelable} defaultPrevented: ${event.defaultPrevented} <br>`; | ||
}, false); | ||
|
||
body.addEventListener("touchmove", function(event) { | ||
event.preventDefault(); | ||
output += `touchmove on body - cancelable: ${event.cancelable} defaultPrevented: ${event.defaultPrevented} <br>`; | ||
}, false); | ||
|
||
body.addEventListener("touchend", function(event) { | ||
event.preventDefault(); | ||
output += `touchend on body - cancelable: ${event.cancelable} defaultPrevented: ${event.defaultPrevented} <br>`; | ||
}, false); | ||
|
||
if (testRunner.runUIScript) { | ||
testRunner.runUIScript(getUIScript(), function(result) { | ||
output += result; | ||
document.getElementById("output").innerHTML = output; | ||
testRunner.notifyDone(); | ||
}); | ||
} | ||
} | ||
|
||
window.addEventListener('load', runTest, false); | ||
</script> | ||
<body style="height: 500vh"> | ||
<div id=output> | ||
This test requires UIScriptController to run. | ||
</div> | ||
</body> |
13 changes: 13 additions & 0 deletions
13
...s/fast/events/touch/ios/passive-by-default-overridden-on-document-and-window-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
touchstart on body - cancelable: true defaultPrevented: true | ||
touchstart on documentElement - cancelable: true defaultPrevented: true | ||
touchstart on document - cancelable: true defaultPrevented: true | ||
touchstart on window - cancelable: true defaultPrevented: true | ||
touchmove on body - cancelable: true defaultPrevented: true | ||
touchmove on documentElement - cancelable: true defaultPrevented: true | ||
touchmove on document - cancelable: true defaultPrevented: true | ||
touchmove on window - cancelable: true defaultPrevented: true | ||
touchend on body - cancelable: true defaultPrevented: true | ||
touchend on documentElement - cancelable: true defaultPrevented: true | ||
touchend on document - cancelable: true defaultPrevented: true | ||
touchend on window - cancelable: true defaultPrevented: true | ||
Done |
97 changes: 97 additions & 0 deletions
97
LayoutTests/fast/events/touch/ios/passive-by-default-overridden-on-document-and-window.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
<script> | ||
if (window.testRunner) { | ||
testRunner.dumpAsText(); | ||
testRunner.waitUntilDone(); | ||
} | ||
|
||
function getUIScript() | ||
{ | ||
return ` | ||
(function() { | ||
uiController.dragFromPointToPoint(50, 250, 50, 30, 0.1, function() { | ||
uiController.uiScriptComplete("Done"); | ||
}); | ||
})();` | ||
} | ||
|
||
function runTest() | ||
{ | ||
let output = ""; | ||
window.addEventListener("touchstart", function(event) { | ||
event.preventDefault(); | ||
output += `touchstart on window - cancelable: ${event.cancelable} defaultPrevented: ${event.defaultPrevented} <br>`; | ||
}, { "passive": false }); | ||
|
||
window.addEventListener("touchmove", function(event) { | ||
event.preventDefault(); | ||
output += `touchmove on window - cancelable: ${event.cancelable} defaultPrevented: ${event.defaultPrevented} <br>`; | ||
}, { "passive": false }); | ||
|
||
window.addEventListener("touchend", function(event) { | ||
event.preventDefault(); | ||
output += `touchend on window - cancelable: ${event.cancelable} defaultPrevented: ${event.defaultPrevented} <br>`; | ||
}, { "passive": false }); | ||
|
||
document.addEventListener("touchstart", function(event) { | ||
event.preventDefault(); | ||
output += `touchstart on document - cancelable: ${event.cancelable} defaultPrevented: ${event.defaultPrevented} <br>`; | ||
}, { "passive": false }); | ||
|
||
document.addEventListener("touchmove", function(event) { | ||
event.preventDefault(); | ||
output += `touchmove on document - cancelable: ${event.cancelable} defaultPrevented: ${event.defaultPrevented} <br>`; | ||
}, { "passive": false }); | ||
|
||
document.addEventListener("touchend", function(event) { | ||
event.preventDefault(); | ||
output += `touchend on document - cancelable: ${event.cancelable} defaultPrevented: ${event.defaultPrevented} <br>`; | ||
}, { "passive": false }); | ||
|
||
document.documentElement.addEventListener("touchstart", function(event) { | ||
event.preventDefault(); | ||
output += `touchstart on documentElement - cancelable: ${event.cancelable} defaultPrevented: ${event.defaultPrevented} <br>`; | ||
}, { "passive": false }); | ||
|
||
document.documentElement.addEventListener("touchmove", function(event) { | ||
event.preventDefault(); | ||
output += `touchmove on documentElement - cancelable: ${event.cancelable} defaultPrevented: ${event.defaultPrevented} <br>`; | ||
}, { "passive": false }); | ||
|
||
document.documentElement.addEventListener("touchend", function(event) { | ||
event.preventDefault(); | ||
output += `touchend on documentElement - cancelable: ${event.cancelable} defaultPrevented: ${event.defaultPrevented} <br>`; | ||
}, { "passive": false }); | ||
|
||
let body = document.querySelector("body"); | ||
|
||
body.addEventListener("touchstart", function(event) { | ||
event.preventDefault(); | ||
output += `touchstart on body - cancelable: ${event.cancelable} defaultPrevented: ${event.defaultPrevented} <br>`; | ||
}, { "passive": false }); | ||
|
||
body.addEventListener("touchmove", function(event) { | ||
event.preventDefault(); | ||
output += `touchmove on body - cancelable: ${event.cancelable} defaultPrevented: ${event.defaultPrevented} <br>`; | ||
}, { "passive": false }); | ||
|
||
body.addEventListener("touchend", function(event) { | ||
event.preventDefault(); | ||
output += `touchend on body - cancelable: ${event.cancelable} defaultPrevented: ${event.defaultPrevented} <br>`; | ||
}, { "passive": false }); | ||
|
||
if (testRunner.runUIScript) { | ||
testRunner.runUIScript(getUIScript(), function(result) { | ||
output += result; | ||
document.getElementById("output").innerHTML = output; | ||
testRunner.notifyDone(); | ||
}); | ||
} | ||
} | ||
|
||
window.addEventListener('load', runTest, false); | ||
</script> | ||
<body style="height: 500vh"> | ||
<div id=output> | ||
This test requires UIScriptController to run. | ||
</div> | ||
</body> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters