Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(12)

Unified Diff: third_party/WebKit/LayoutTests/fast/events/inputevents/beforeinput-remove-iframe-crash.html

Issue 2258663003: [InputEvent] Support |deleteByCut|&|insertFromPaste| with |dataTransfer| field (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: yosin's review2, fix nits Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/fast/events/inputevents/inputevent-cut-paste.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/LayoutTests/fast/events/inputevents/beforeinput-remove-iframe-crash.html
diff --git a/third_party/WebKit/LayoutTests/fast/events/inputevents/beforeinput-remove-iframe-crash.html b/third_party/WebKit/LayoutTests/fast/events/inputevents/beforeinput-remove-iframe-crash.html
new file mode 100644
index 0000000000000000000000000000000000000000..bcc1427fc8c1b34f4de5afdcec0495805229b55c
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/fast/events/inputevents/beforeinput-remove-iframe-crash.html
@@ -0,0 +1,71 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>InputEvent: beforeinput shouldn't crash in removed iframe</title>
+<script src="../../../resources/testharness.js"></script>
+<script src="../../../resources/testharnessreport.js"></script>
+</head>
+<body>
+<script>
+test(function() {
+ assert_not_equals(window.eventSender, undefined, 'This test requires eventSender.');
+ assert_not_equals(window.testRunner, undefined, 'This test requires testRunner.');
+
+ function testBeforeInputCrash(expectedBeforeInputCount, beforeInputTrigger, comments) {
+ const iframe = document.createElement('iframe');
+ document.body.appendChild(iframe);
+ const childDocument = iframe.contentDocument;
+ childDocument.body.innerHTML = '<p id="editable" contenteditable>Foo</p>';
+
+ var actualBeforeInputCount = 0;
+ const editable = childDocument.getElementById('editable');
+ editable.addEventListener('beforeinput', event => {
+ actualBeforeInputCount++;
+ if (actualBeforeInputCount == expectedBeforeInputCount && iframe.parentNode)
+ iframe.remove();
+ });
+
+ editable.focus();
+ beforeInputTrigger(childDocument, editable);
+
+ if (iframe.parentNode)
+ iframe.remove();
+ assert_equals(actualBeforeInputCount, expectedBeforeInputCount, comments);
+ }
+
+ // Text command.
+ testBeforeInputCrash(1, () => eventSender.keyDown('a'), 'Testing insertText "a"');
+ testBeforeInputCrash(1, () => eventSender.keyDown('Enter', ['shiftKey']), 'Testing insertLineBreak');
+ testBeforeInputCrash(1, () => eventSender.keyDown('Delete'), 'Testing deleteCharacterForward');
+
+ // Styling command.
+ testBeforeInputCrash(1, (childDocument, editable) => {
+ var selection = childDocument.getSelection();
+ selection.collapse(editable, 0);
+ selection.extend(editable, 1);
+ testRunner.execCommand('bold');
+ }, 'Testing bold');
+
+ // Cut & Paste.
+ testBeforeInputCrash(1, (childDocument, editable) => {
+ var selection = childDocument.getSelection();
+ selection.collapse(editable, 0);
+ selection.extend(editable, 1);
+ eventSender.keyDown('Cut');
+ }, 'Testing deleteByCut');
+ testBeforeInputCrash(1, () => eventSender.keyDown('Paste'), 'Testing insertFromPaste');
+
+ // Undo & Redo.
+ testBeforeInputCrash(2, () => {
+ eventSender.keyDown('a');
+ testRunner.execCommand('undo');
+ }, 'Testing undo');
+ testBeforeInputCrash(3, () => {
+ eventSender.keyDown('a');
+ testRunner.execCommand('undo');
+ testRunner.execCommand('redo');
+ }, 'Testing redo');
+}, 'Testing beforeinput in removed iframe');
+</script>
+</body>
+</html>
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/fast/events/inputevents/inputevent-cut-paste.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698