Skip to content
Permalink
Browse files
Expand r209943 to suppress paste during provisional navigation as well
https://bugs.webkit.org/show_bug.cgi?id=178429
<rdar://problem/33952830>

Reviewed by Dean Jackson.

Source/WebCore:

No new tests; adjusted an existing test to cover this case.

* editing/Editor.cpp:
(WebCore::Editor::canPaste const):
Disable pasting during provisional navigation, like r209943 did for
various other forms of text input.

(WebCore::Editor::shouldInsertText const):
* dom/EventDispatcher.cpp:
(WebCore::shouldSuppressEventDispatchInDOM):
* loader/FrameLoader.cpp:
(WebCore::FrameLoader::shouldSuppressTextInputFromEditing const):
(WebCore::FrameLoader::shouldSuppressKeyboardInput const): Deleted.
* loader/FrameLoader.h:
* page/Settings.in:
Rename the setting to be about editing-related text input, not "keyboard" input.

* editing/EditorCommand.cpp:
(WebCore::allowExecutionWhenDisabled):
(WebCore::doNotAllowExecutionWhenDisabled):
(WebCore::allowExecutionWhenDisabledCopyCut):
(WebCore::allowExecutionWhenDisabledPaste):
(WebCore::createCommandMap):
(WebCore::Editor::Command::allowExecutionWhenDisabled const):
Completely disable execution of paste events when in no-text-input-from-editing mode.
Otherwise, even though canPaste was false and we wouldn't do a default paste action,
we would still dispatch the paste event to the DOM.

Source/WebKit:

* Shared/WebPreferencesDefinitions.h:
* UIProcess/API/C/WKPreferences.cpp:
(WKPreferencesSetShouldSuppressKeyboardInputDuringProvisionalNavigation):
(WKPreferencesGetShouldSuppressKeyboardInputDuringProvisionalNavigation):
* UIProcess/API/Cocoa/WKPreferences.mm:
(-[WKPreferences _shouldSuppressKeyboardInputDuringProvisionalNavigation]):
(-[WKPreferences _setShouldSuppressKeyboardInputDuringProvisionalNavigation:]):
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::updatePreferences):
Adjust to the changed preference name, except at the SPI level.

LayoutTests:

* http/tests/navigation/keyboard-events-during-provisional-navigation-expected.txt:
* http/tests/navigation/keyboard-events-during-provisional-navigation.html:
* http/tests/navigation/keyboard-events-during-provisional-subframe-navigation-expected.txt:
* http/tests/navigation/keyboard-events-during-provisional-subframe-navigation.html:
* http/tests/navigation/resources/keyboard-events-after-navigation.html:
* http/tests/navigation/resources/keyboard-events-test.js:
(runBeforeTest):
(runTest):
Copy a "d" to the clipboard before running the test, and paste it while running.
I put the copy before running the test so that if someone comes along and
blacklists copy during provisional load as well, the test for this behavior
still actually tests the paste portion.
Also ensure that paste events are not triggered during provisional navigation.


Canonical link: https://commits.webkit.org/194724@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@223708 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
hortont424 committed Oct 19, 2017
1 parent 7b39b66 commit 5d2b4bec66d3ec2155d8649674a79356049652d7
@@ -1,3 +1,25 @@
2017-10-19 Tim Horton <timothy_horton@apple.com>

Expand r209943 to suppress paste during provisional navigation as well
https://bugs.webkit.org/show_bug.cgi?id=178429
<rdar://problem/33952830>

Reviewed by Dean Jackson.

* http/tests/navigation/keyboard-events-during-provisional-navigation-expected.txt:
* http/tests/navigation/keyboard-events-during-provisional-navigation.html:
* http/tests/navigation/keyboard-events-during-provisional-subframe-navigation-expected.txt:
* http/tests/navigation/keyboard-events-during-provisional-subframe-navigation.html:
* http/tests/navigation/resources/keyboard-events-after-navigation.html:
* http/tests/navigation/resources/keyboard-events-test.js:
(runBeforeTest):
(runTest):
Copy a "d" to the clipboard before running the test, and paste it while running.
I put the copy before running the test so that if someone comes along and
blacklists copy during provisional load as well, the test for this behavior
still actually tests the paste portion.
Also ensure that paste events are not triggered during provisional navigation.

2017-10-19 Daniel Bates <dabates@apple.com>

Referrer policy should be inherited from creator
@@ -1,40 +1,46 @@
CONSOLE MESSAGE: line 14: Provisional navigation started.
CONSOLE MESSAGE: line 15: No trusted events should be logged and the input element should have the value "".
CONSOLE MESSAGE: line 20: Dispatching untrusted keypress event.
CONSOLE MESSAGE: line 5: keypressevent dispatched (isTrusted: false).
CONSOLE MESSAGE: line 28: Pressing tab.
CONSOLE MESSAGE: line 30: Active element after pressing tab: [object HTMLInputElement].
CONSOLE MESSAGE: line 32: Pressing "a".
CONSOLE MESSAGE: line 35: Setting marked text to "b".
CONSOLE MESSAGE: line 38: Inserting text "c".
CONSOLE MESSAGE: line 41: Input element value after text input events: "".
CONSOLE MESSAGE: line 18: Pressing "z" with access key modifiers should navigate to resources/keyboard-events-after-navigation.html.
CONSOLE MESSAGE: line 16: Provisional navigation started.
CONSOLE MESSAGE: line 17: No trusted events should be logged and the input element should have the value "".
CONSOLE MESSAGE: line 34: Dispatching untrusted keypress event.
CONSOLE MESSAGE: line 18: keypressevent dispatched (isTrusted: false).
CONSOLE MESSAGE: line 42: Pressing tab.
CONSOLE MESSAGE: line 44: Active element after pressing tab: [object HTMLInputElement].
CONSOLE MESSAGE: line 46: Pressing "a".
CONSOLE MESSAGE: line 49: Setting marked text to "b".
CONSOLE MESSAGE: line 52: Inserting text "c".
CONSOLE MESSAGE: line 55: Pasting text "d".
CONSOLE MESSAGE: line 58: Input element value after text input events: "".
CONSOLE MESSAGE: line 20: Pressing "z" with access key modifiers should navigate to resources/keyboard-events-after-navigation.html.
CONSOLE MESSAGE: line 6: Finished navigating to resources/keyboard-events-after-navigation.html.
CONSOLE MESSAGE: line 7: Trusted events should be logged and the input element should have the value "ac".
CONSOLE MESSAGE: line 20: Dispatching untrusted keypress event.
CONSOLE MESSAGE: line 5: keypressevent dispatched (isTrusted: false).
CONSOLE MESSAGE: line 28: Pressing tab.
CONSOLE MESSAGE: line 5: keydownevent dispatched (isTrusted: true).
CONSOLE MESSAGE: line 5: keyupevent dispatched (isTrusted: true).
CONSOLE MESSAGE: line 30: Active element after pressing tab: [object HTMLInputElement].
CONSOLE MESSAGE: line 32: Pressing "a".
CONSOLE MESSAGE: line 5: keydownevent dispatched (isTrusted: true).
CONSOLE MESSAGE: line 5: keypressevent dispatched (isTrusted: true).
CONSOLE MESSAGE: line 5: textInputevent dispatched (isTrusted: true).
CONSOLE MESSAGE: line 5: beforeinputevent dispatched (isTrusted: true).
CONSOLE MESSAGE: line 5: inputevent dispatched (isTrusted: true).
CONSOLE MESSAGE: line 5: keyupevent dispatched (isTrusted: true).
CONSOLE MESSAGE: line 35: Setting marked text to "b".
CONSOLE MESSAGE: line 5: compositionstartevent dispatched (isTrusted: true).
CONSOLE MESSAGE: line 5: compositionupdateevent dispatched (isTrusted: true).
CONSOLE MESSAGE: line 5: beforeinputevent dispatched (isTrusted: true).
CONSOLE MESSAGE: line 5: inputevent dispatched (isTrusted: true).
CONSOLE MESSAGE: line 38: Inserting text "c".
CONSOLE MESSAGE: line 5: beforeinputevent dispatched (isTrusted: true).
CONSOLE MESSAGE: line 5: inputevent dispatched (isTrusted: true).
CONSOLE MESSAGE: line 5: textInputevent dispatched (isTrusted: true).
CONSOLE MESSAGE: line 5: beforeinputevent dispatched (isTrusted: true).
CONSOLE MESSAGE: line 5: inputevent dispatched (isTrusted: true).
CONSOLE MESSAGE: line 5: compositionendevent dispatched (isTrusted: true).
CONSOLE MESSAGE: line 41: Input element value after text input events: "ac".
CONSOLE MESSAGE: line 7: Trusted events should be logged and the input element should have the value "acd".
CONSOLE MESSAGE: line 34: Dispatching untrusted keypress event.
CONSOLE MESSAGE: line 18: keypressevent dispatched (isTrusted: false).
CONSOLE MESSAGE: line 42: Pressing tab.
CONSOLE MESSAGE: line 18: keydownevent dispatched (isTrusted: true).
CONSOLE MESSAGE: line 18: keyupevent dispatched (isTrusted: true).
CONSOLE MESSAGE: line 44: Active element after pressing tab: [object HTMLInputElement].
CONSOLE MESSAGE: line 46: Pressing "a".
CONSOLE MESSAGE: line 18: keydownevent dispatched (isTrusted: true).
CONSOLE MESSAGE: line 18: keypressevent dispatched (isTrusted: true).
CONSOLE MESSAGE: line 18: textInputevent dispatched (isTrusted: true).
CONSOLE MESSAGE: line 18: beforeinputevent dispatched (isTrusted: true).
CONSOLE MESSAGE: line 18: inputevent dispatched (isTrusted: true).
CONSOLE MESSAGE: line 18: keyupevent dispatched (isTrusted: true).
CONSOLE MESSAGE: line 49: Setting marked text to "b".
CONSOLE MESSAGE: line 18: compositionstartevent dispatched (isTrusted: true).
CONSOLE MESSAGE: line 18: compositionupdateevent dispatched (isTrusted: true).
CONSOLE MESSAGE: line 18: beforeinputevent dispatched (isTrusted: true).
CONSOLE MESSAGE: line 18: inputevent dispatched (isTrusted: true).
CONSOLE MESSAGE: line 52: Inserting text "c".
CONSOLE MESSAGE: line 18: beforeinputevent dispatched (isTrusted: true).
CONSOLE MESSAGE: line 18: inputevent dispatched (isTrusted: true).
CONSOLE MESSAGE: line 18: textInputevent dispatched (isTrusted: true).
CONSOLE MESSAGE: line 18: beforeinputevent dispatched (isTrusted: true).
CONSOLE MESSAGE: line 18: inputevent dispatched (isTrusted: true).
CONSOLE MESSAGE: line 18: compositionendevent dispatched (isTrusted: true).
CONSOLE MESSAGE: line 55: Pasting text "d".
CONSOLE MESSAGE: line 18: pasteevent dispatched (isTrusted: true).
CONSOLE MESSAGE: line 18: textInputevent dispatched (isTrusted: true).
CONSOLE MESSAGE: line 18: beforeinputevent dispatched (isTrusted: true).
CONSOLE MESSAGE: line 18: inputevent dispatched (isTrusted: true).
CONSOLE MESSAGE: line 58: Input element value after text input events: "acd".

@@ -7,9 +7,11 @@
if (window.testRunner) {
testRunner.dumpAsText();
testRunner.waitUntilDone();
internals.settings.setShouldSuppressKeyboardInputDuringProvisionalNavigation(true);
internals.settings.setShouldSuppressTextInputFromEditingDuringProvisionalNavigation(true);
}

runBeforeTest(window);

waitForProvisionalNavigation(function() {
console.log("Provisional navigation started.");
console.log("No trusted events should be logged and the input element should have the value \"\".");
@@ -1,40 +1,46 @@
CONSOLE MESSAGE: line 16: Provisional navigation started.
CONSOLE MESSAGE: line 17: No trusted events should be logged and the input element should have the value "".
CONSOLE MESSAGE: line 20: Dispatching untrusted keypress event.
CONSOLE MESSAGE: line 5: keypressevent dispatched (isTrusted: false).
CONSOLE MESSAGE: line 28: Pressing tab.
CONSOLE MESSAGE: line 30: Active element after pressing tab: [object HTMLInputElement].
CONSOLE MESSAGE: line 32: Pressing "a".
CONSOLE MESSAGE: line 35: Setting marked text to "b".
CONSOLE MESSAGE: line 38: Inserting text "c".
CONSOLE MESSAGE: line 41: Input element value after text input events: "".
CONSOLE MESSAGE: line 20: Pressing "z" with access key modifiers should navigate to resources/keyboard-events-after-navigation.html.
CONSOLE MESSAGE: line 18: Provisional navigation started.
CONSOLE MESSAGE: line 19: No trusted events should be logged and the input element should have the value "".
CONSOLE MESSAGE: line 34: Dispatching untrusted keypress event.
CONSOLE MESSAGE: line 18: keypressevent dispatched (isTrusted: false).
CONSOLE MESSAGE: line 42: Pressing tab.
CONSOLE MESSAGE: line 44: Active element after pressing tab: [object HTMLInputElement].
CONSOLE MESSAGE: line 46: Pressing "a".
CONSOLE MESSAGE: line 49: Setting marked text to "b".
CONSOLE MESSAGE: line 52: Inserting text "c".
CONSOLE MESSAGE: line 55: Pasting text "d".
CONSOLE MESSAGE: line 58: Input element value after text input events: "".
CONSOLE MESSAGE: line 22: Pressing "z" with access key modifiers should navigate to resources/keyboard-events-after-navigation.html.
CONSOLE MESSAGE: line 6: Finished navigating to resources/keyboard-events-after-navigation.html.
CONSOLE MESSAGE: line 7: Trusted events should be logged and the input element should have the value "ac".
CONSOLE MESSAGE: line 20: Dispatching untrusted keypress event.
CONSOLE MESSAGE: line 5: keypressevent dispatched (isTrusted: false).
CONSOLE MESSAGE: line 28: Pressing tab.
CONSOLE MESSAGE: line 5: keydownevent dispatched (isTrusted: true).
CONSOLE MESSAGE: line 5: keyupevent dispatched (isTrusted: true).
CONSOLE MESSAGE: line 30: Active element after pressing tab: [object HTMLInputElement].
CONSOLE MESSAGE: line 32: Pressing "a".
CONSOLE MESSAGE: line 5: keydownevent dispatched (isTrusted: true).
CONSOLE MESSAGE: line 5: keypressevent dispatched (isTrusted: true).
CONSOLE MESSAGE: line 5: textInputevent dispatched (isTrusted: true).
CONSOLE MESSAGE: line 5: beforeinputevent dispatched (isTrusted: true).
CONSOLE MESSAGE: line 5: inputevent dispatched (isTrusted: true).
CONSOLE MESSAGE: line 5: keyupevent dispatched (isTrusted: true).
CONSOLE MESSAGE: line 35: Setting marked text to "b".
CONSOLE MESSAGE: line 5: compositionstartevent dispatched (isTrusted: true).
CONSOLE MESSAGE: line 5: compositionupdateevent dispatched (isTrusted: true).
CONSOLE MESSAGE: line 5: beforeinputevent dispatched (isTrusted: true).
CONSOLE MESSAGE: line 5: inputevent dispatched (isTrusted: true).
CONSOLE MESSAGE: line 38: Inserting text "c".
CONSOLE MESSAGE: line 5: beforeinputevent dispatched (isTrusted: true).
CONSOLE MESSAGE: line 5: inputevent dispatched (isTrusted: true).
CONSOLE MESSAGE: line 5: textInputevent dispatched (isTrusted: true).
CONSOLE MESSAGE: line 5: beforeinputevent dispatched (isTrusted: true).
CONSOLE MESSAGE: line 5: inputevent dispatched (isTrusted: true).
CONSOLE MESSAGE: line 5: compositionendevent dispatched (isTrusted: true).
CONSOLE MESSAGE: line 41: Input element value after text input events: "ac".
CONSOLE MESSAGE: line 7: Trusted events should be logged and the input element should have the value "acd".
CONSOLE MESSAGE: line 34: Dispatching untrusted keypress event.
CONSOLE MESSAGE: line 18: keypressevent dispatched (isTrusted: false).
CONSOLE MESSAGE: line 42: Pressing tab.
CONSOLE MESSAGE: line 18: keydownevent dispatched (isTrusted: true).
CONSOLE MESSAGE: line 18: keyupevent dispatched (isTrusted: true).
CONSOLE MESSAGE: line 44: Active element after pressing tab: [object HTMLInputElement].
CONSOLE MESSAGE: line 46: Pressing "a".
CONSOLE MESSAGE: line 18: keydownevent dispatched (isTrusted: true).
CONSOLE MESSAGE: line 18: keypressevent dispatched (isTrusted: true).
CONSOLE MESSAGE: line 18: textInputevent dispatched (isTrusted: true).
CONSOLE MESSAGE: line 18: beforeinputevent dispatched (isTrusted: true).
CONSOLE MESSAGE: line 18: inputevent dispatched (isTrusted: true).
CONSOLE MESSAGE: line 18: keyupevent dispatched (isTrusted: true).
CONSOLE MESSAGE: line 49: Setting marked text to "b".
CONSOLE MESSAGE: line 18: compositionstartevent dispatched (isTrusted: true).
CONSOLE MESSAGE: line 18: compositionupdateevent dispatched (isTrusted: true).
CONSOLE MESSAGE: line 18: beforeinputevent dispatched (isTrusted: true).
CONSOLE MESSAGE: line 18: inputevent dispatched (isTrusted: true).
CONSOLE MESSAGE: line 52: Inserting text "c".
CONSOLE MESSAGE: line 18: beforeinputevent dispatched (isTrusted: true).
CONSOLE MESSAGE: line 18: inputevent dispatched (isTrusted: true).
CONSOLE MESSAGE: line 18: textInputevent dispatched (isTrusted: true).
CONSOLE MESSAGE: line 18: beforeinputevent dispatched (isTrusted: true).
CONSOLE MESSAGE: line 18: inputevent dispatched (isTrusted: true).
CONSOLE MESSAGE: line 18: compositionendevent dispatched (isTrusted: true).
CONSOLE MESSAGE: line 55: Pasting text "d".
CONSOLE MESSAGE: line 18: pasteevent dispatched (isTrusted: true).
CONSOLE MESSAGE: line 18: textInputevent dispatched (isTrusted: true).
CONSOLE MESSAGE: line 18: beforeinputevent dispatched (isTrusted: true).
CONSOLE MESSAGE: line 18: inputevent dispatched (isTrusted: true).
CONSOLE MESSAGE: line 58: Input element value after text input events: "acd".

@@ -9,9 +9,11 @@
testRunner.dumpAsText();
testRunner.dumpChildFramesAsText();
testRunner.waitUntilDone();
internals.settings.setShouldSuppressKeyboardInputDuringProvisionalNavigation(true);
internals.settings.setShouldSuppressTextInputFromEditingDuringProvisionalNavigation(true);
}

runBeforeTest(window);

waitForProvisionalNavigation(function () {
console.log("Provisional navigation started.");
console.log("No trusted events should be logged and the input element should have the value \"\".");
@@ -4,7 +4,7 @@
<script src="keyboard-events-test.js"></script>
<script>
console.log("Finished navigating to resources/keyboard-events-after-navigation.html.");
console.log("Trusted events should be logged and the input element should have the value \"ac\".");
console.log("Trusted events should be logged and the input element should have the value \"acd\".");
runTest(window);
testRunner.notifyDone();
</script>
@@ -1,3 +1,16 @@
function runBeforeTest(window)
{
var document = window.document;

document.body.addEventListener("beforecopy", function (e) { e.preventDefault(); });
document.body.addEventListener("copy", function (e) {
e.clipboardData.setData("text/plain", "d");
e.preventDefault();
});

document.execCommand("copy");
}

function runTest(window)
{
function eventHandler(event)
@@ -14,6 +27,7 @@ function runTest(window)
window.addEventListener("textInput", eventHandler, true);
window.addEventListener("beforeinput", eventHandler, true);
window.addEventListener("input", eventHandler, true);
window.addEventListener("paste", eventHandler, true);

var document = window.document;

@@ -38,6 +52,9 @@ function runTest(window)
console.log("Inserting text \"c\".");
textInputController.insertText("c");

console.log("Pasting text \"d\".");
document.execCommand("Paste");

console.log("Input element value after text input events: \"" + textInput.value + "\".");
}

@@ -1,3 +1,39 @@
2017-10-19 Tim Horton <timothy_horton@apple.com>

Expand r209943 to suppress paste during provisional navigation as well
https://bugs.webkit.org/show_bug.cgi?id=178429
<rdar://problem/33952830>

Reviewed by Dean Jackson.

No new tests; adjusted an existing test to cover this case.

* editing/Editor.cpp:
(WebCore::Editor::canPaste const):
Disable pasting during provisional navigation, like r209943 did for
various other forms of text input.

(WebCore::Editor::shouldInsertText const):
* dom/EventDispatcher.cpp:
(WebCore::shouldSuppressEventDispatchInDOM):
* loader/FrameLoader.cpp:
(WebCore::FrameLoader::shouldSuppressTextInputFromEditing const):
(WebCore::FrameLoader::shouldSuppressKeyboardInput const): Deleted.
* loader/FrameLoader.h:
* page/Settings.in:
Rename the setting to be about editing-related text input, not "keyboard" input.

* editing/EditorCommand.cpp:
(WebCore::allowExecutionWhenDisabled):
(WebCore::doNotAllowExecutionWhenDisabled):
(WebCore::allowExecutionWhenDisabledCopyCut):
(WebCore::allowExecutionWhenDisabledPaste):
(WebCore::createCommandMap):
(WebCore::Editor::Command::allowExecutionWhenDisabled const):
Completely disable execution of paste events when in no-text-input-from-editing mode.
Otherwise, even though canPaste was false and we wouldn't do a default paste action,
we would still dispatch the paste event to the DOM.

2017-10-19 Dean Jackson <dino@apple.com>

Avoid duplicate multisample resolve before WebGL compositing
@@ -117,7 +117,7 @@ static bool shouldSuppressEventDispatchInDOM(Node& node, Event& event)
if (!frame)
return false;

if (!frame->mainFrame().loader().shouldSuppressKeyboardInput())
if (!frame->mainFrame().loader().shouldSuppressTextInputFromEditing())
return false;

if (is<TextEvent>(event)) {
@@ -456,6 +456,9 @@ bool Editor::canCopy() const

bool Editor::canPaste() const
{
if (m_frame.mainFrame().loader().shouldSuppressTextInputFromEditing())
return false;

return canEdit();
}

@@ -704,7 +707,7 @@ bool Editor::tryDHTMLCut()

bool Editor::shouldInsertText(const String& text, Range* range, EditorInsertAction action) const
{
if (m_frame.mainFrame().loader().shouldSuppressKeyboardInput() && action == EditorInsertAction::Typed)
if (m_frame.mainFrame().loader().shouldSuppressTextInputFromEditing() && action == EditorInsertAction::Typed)
return false;

return client() && client()->shouldInsertText(text, range, action);

0 comments on commit 5d2b4be

Please sign in to comment.