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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <script src="../../../resources/js-test.js"></script>
3 <body>
4 <script>
5 description("This tests the constructor for the ClipboardEvent DOM class.");
6
7 //No Initializer is passed
8 shouldBe("new ClipboardEvent('eventType').bubbles", "false");
9 shouldBe("new ClipboardEvent('eventType').cancelable", "false");
10
11 // bubbles is passed.
12 shouldBe("new ClipboardEvent('eventType', { bubbles: false }).bubbles", "false") ;
13 shouldBe("new ClipboardEvent('eventType', { bubbles: true }).bubbles", "true");
14
15 // cancelable is passed.
16 shouldBe("new ClipboardEvent('eventType', { cancelable: false }).cancelable", "f alse");
17 shouldBe("new ClipboardEvent('eventType', { cancelable: true }).cancelable", "tr ue");
18
19 //text data is passed
20 shouldBeEqualToString("new ClipboardEvent('cut', { data: 'hellodata', dataType: 'text' }).clipboardData.getData('text')", "hellodata");
21 shouldBeEqualToString("new ClipboardEvent('copy', { data: 'hellodata', dataType: 'text' }).clipboardData.getData('text')", "hellodata");
22 shouldBeEqualToString("new ClipboardEvent('paste', { data: 'hellodata', dataType : 'text' }).clipboardData.getData('text')", "hellodata");
23
24 //url data is passed
25 shouldBeEqualToString("new ClipboardEvent('cut', { data: 'http://www.google.com/ ', dataType: 'url' }).clipboardData.getData('url')", "http://www.google.com/");
26 shouldBeEqualToString("new ClipboardEvent('copy', { data: 'http://www.google.com /', dataType: 'url' }).clipboardData.getData('url')", "http://www.google.com/");
27 shouldBeEqualToString("new ClipboardEvent('paste', { data: 'http://www.google.co m/', dataType: 'url' }).clipboardData.getData('url')", "http://www.google.com/") ;
28
29 //html data is passed
30 shouldBeEqualToString("new ClipboardEvent('cut', { data: '<em>Markup</em>', data Type: 'html' }).clipboardData.getData('html')", "<em>Markup</em>");
31 shouldBeEqualToString("new ClipboardEvent('copy', { data: '<em>Markup</em>', dat aType: 'html' }).clipboardData.getData('html')", "<em>Markup</em>");
32 shouldBeEqualToString("new ClipboardEvent('paste', { data: '<em>Markup</em>', da taType: 'html' }).clipboardData.getData('html')", "<em>Markup</em>");
33
34 //no dataType is passed
35 shouldBeEqualToString("new ClipboardEvent('copy', { data: '<em>Markup</em>'}).cl ipboardData.getData('html')", "");
36 shouldBeEqualToString("new ClipboardEvent('copy', { data: '<em>Markup</em>'}).cl ipboardData.getData('html')", "");
37
38 // Non-strings.
39 shouldBeEqualToString("new ClipboardEvent('copy', { data: undefined, dataType: ' text' }).clipboardData.getData('text')", "");
40 shouldBeEqualToString("new ClipboardEvent('copy', { data: null, dataType: 'text' }).clipboardData.getData('text')", "null");
41 shouldBeEqualToString("new ClipboardEvent('copy', { data: false, dataType: 'text ' }).clipboardData.getData('text')", "false");
42 shouldBeEqualToString("new ClipboardEvent('copy', { data: true, dataType: 'text' }).clipboardData.getData('text')", "true");
43 shouldBeEqualToString("new ClipboardEvent('copy', { data: 12345, dataType: 'text ' }).clipboardData.getData('text')", "12345");
44 shouldBeEqualToString("new ClipboardEvent('copy', { data: 18446744073709551615, dataType: 'text' }).clipboardData.getData('text')", "18446744073709552000");
45 shouldBeEqualToString("new ClipboardEvent('copy', { data: NaN, dataType: 'text' }).clipboardData.getData('text')", "NaN");
46 shouldBeEqualToString("new ClipboardEvent('copy', { data: [], dataType: 'text' } ).clipboardData.getData('text')", "");
47 shouldBeEqualToString("new ClipboardEvent('copy', { data: [1, 2, 3], dataType: ' text' }).clipboardData.getData('text')", "1,2,3");
48
49 // All initializers are passed.
50 shouldBe("new ClipboardEvent('eventType', { bubbles: true, cancelable: true, dat a: 'http://www.google.com/', dataType: 'url' }).bubbles", "true");
51 shouldBe("new ClipboardEvent('eventType', { bubbles: true, cancelable: true, dat a: 'http://www.google.com/', dataType: 'url' }).cancelable", "true");
52 shouldBeEqualToString("new ClipboardEvent('copy', { bubbles: true, cancelable: t rue, data: 'http://www.google.com/', dataType: 'url' }).clipboardData.getData('u rl')", "http://www.google.com/");
53
54 //invalid eventType
55 shouldBeEqualToString("new ClipboardEvent('invalid', { bubbles: true, cancelable : true, data: 'http://www.google.com/', dataType: 'url' }).clipboardData.getData ('url')", "");
56 //no eventType specified
57 shouldBeEqualToString("new ClipboardEvent({ bubbles: true, cancelable: true, dat a: 'http://www.google.com/', dataType: 'url' }).clipboardData.getData('url')", " ");
58 </script>
59 </body>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698