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

Unified Diff: LayoutTests/fast/events/constructors/clipboard-event-constructor.html

Issue 1178683007: Introducing ClipboardEvent Constructor Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 6 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 | LayoutTests/fast/events/constructors/clipboard-event-constructor-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: LayoutTests/fast/events/constructors/clipboard-event-constructor.html
diff --git a/LayoutTests/fast/events/constructors/clipboard-event-constructor.html b/LayoutTests/fast/events/constructors/clipboard-event-constructor.html
new file mode 100644
index 0000000000000000000000000000000000000000..132696cf67987d1f5f59bb0457579ff150cc33bd
--- /dev/null
+++ b/LayoutTests/fast/events/constructors/clipboard-event-constructor.html
@@ -0,0 +1,66 @@
+<!DOCTYPE html>
+<script src="../../../resources/js-test.js"></script>
+<body>
+<div id="divTag">DefaultText</div>
+<script>
+description("This tests the constructor for the ClipboardEvent DOM class.");
+
+//No Initializer is passed
+shouldBe("new ClipboardEvent('eventType').bubbles", "false");
+shouldBe("new ClipboardEvent('eventType').cancelable", "false");
+
+// bubbles is passed.
+shouldBe("new ClipboardEvent('eventType', { bubbles: false }).bubbles", "false");
+shouldBe("new ClipboardEvent('eventType', { bubbles: true }).bubbles", "true");
+
+// cancelable is passed.
+shouldBe("new ClipboardEvent('eventType', { cancelable: false }).cancelable", "false");
+shouldBe("new ClipboardEvent('eventType', { cancelable: true }).cancelable", "true");
+
+//text data is passed
+shouldBeEqualToString("new ClipboardEvent('cut', { data: 'hellodata', dataType: 'text' }).clipboardData.getData('text')", "hellodata");
+shouldBeEqualToString("new ClipboardEvent('copy', { data: 'hellodata', dataType: 'text' }).clipboardData.getData('text')", "hellodata");
+shouldBeEqualToString("new ClipboardEvent('paste', { data: 'hellodata', dataType: 'text' }).clipboardData.getData('text')", "hellodata");
+
+//url data is passed
+shouldBeEqualToString("new ClipboardEvent('cut', { data: 'http://www.google.com/', dataType: 'url' }).clipboardData.getData('url')", "http://www.google.com/");
+shouldBeEqualToString("new ClipboardEvent('copy', { data: 'http://www.google.com/', dataType: 'url' }).clipboardData.getData('url')", "http://www.google.com/");
+shouldBeEqualToString("new ClipboardEvent('paste', { data: 'http://www.google.com/', dataType: 'url' }).clipboardData.getData('url')", "http://www.google.com/");
+
+//html data is passed
+shouldBeEqualToString("new ClipboardEvent('cut', { data: '<em>Markup</em>', dataType: 'html' }).clipboardData.getData('html')", "<em>Markup</em>");
+shouldBeEqualToString("new ClipboardEvent('copy', { data: '<em>Markup</em>', dataType: 'html' }).clipboardData.getData('html')", "<em>Markup</em>");
+shouldBeEqualToString("new ClipboardEvent('paste', { data: '<em>Markup</em>', dataType: 'html' }).clipboardData.getData('html')", "<em>Markup</em>");
+
+//no dataType is passed
+shouldBeEqualToString("new ClipboardEvent('copy', { data: '<em>Markup</em>'}).clipboardData.getData('html')", "");
+shouldBeEqualToString("new ClipboardEvent('copy', { data: '<em>Markup</em>'}).clipboardData.getData('html')", "");
+
+// Non-strings.
+shouldBeEqualToString("new ClipboardEvent('copy', { data: undefined, dataType: 'text' }).clipboardData.getData('text')", "");
+shouldBeEqualToString("new ClipboardEvent('copy', { data: null, dataType: 'text' }).clipboardData.getData('text')", "null");
+shouldBeEqualToString("new ClipboardEvent('copy', { data: false, dataType: 'text' }).clipboardData.getData('text')", "false");
+shouldBeEqualToString("new ClipboardEvent('copy', { data: true, dataType: 'text' }).clipboardData.getData('text')", "true");
+shouldBeEqualToString("new ClipboardEvent('copy', { data: 12345, dataType: 'text' }).clipboardData.getData('text')", "12345");
+shouldBeEqualToString("new ClipboardEvent('copy', { data: 18446744073709551615, dataType: 'text' }).clipboardData.getData('text')", "18446744073709552000");
+shouldBeEqualToString("new ClipboardEvent('copy', { data: NaN, dataType: 'text' }).clipboardData.getData('text')", "NaN");
+shouldBeEqualToString("new ClipboardEvent('copy', { data: [], dataType: 'text' }).clipboardData.getData('text')", "");
+shouldBeEqualToString("new ClipboardEvent('copy', { data: [1, 2, 3], dataType: 'text' }).clipboardData.getData('text')", "1,2,3");
+
+// All initializers are passed.
+shouldBe("new ClipboardEvent('eventType', { bubbles: true, cancelable: true, data: 'http://www.google.com/', dataType: 'url' }).bubbles", "true");
+shouldBe("new ClipboardEvent('eventType', { bubbles: true, cancelable: true, data: 'http://www.google.com/', dataType: 'url' }).cancelable", "true");
+shouldBeEqualToString("new ClipboardEvent('copy', { bubbles: true, cancelable: true, data: 'http://www.google.com/', dataType: 'url' }).clipboardData.getData('url')", "http://www.google.com/");
+
+//invalid eventType
+shouldBeEqualToString("new ClipboardEvent('invalid', { bubbles: true, cancelable: true, data: 'http://www.google.com/', dataType: 'url' }).clipboardData.getData('url')", "");
+//no eventType specified
+shouldBeEqualToString("new ClipboardEvent({ bubbles: true, cancelable: true, data: 'http://www.google.com/', dataType: 'url' }).clipboardData.getData('url')", "");
+
+var event = new ClipboardEvent('paste', { data: 'hellodata', dataType: 'text' });
+var divtag = document.getElementById("divTag");
+divtag.dispatchEvent(event);
+shouldBeEqualToString("divTag.textContent", "DefaultText");
dcheng 2015/06/17 03:00:14 Without a paste handler, this won't change (divs a
+
+</script>
+</body>
« no previous file with comments | « no previous file | LayoutTests/fast/events/constructors/clipboard-event-constructor-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698