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

Unified Diff: LayoutTests/fast/events/clipboard-dataTransferItemList-remove.html

Issue 23051003: Add support for DataTransferItemList.remove() method (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 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 | LayoutTests/fast/events/clipboard-dataTransferItemList-remove-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: LayoutTests/fast/events/clipboard-dataTransferItemList-remove.html
diff --git a/LayoutTests/fast/events/clipboard-dataTransferItemList-remove.html b/LayoutTests/fast/events/clipboard-dataTransferItemList-remove.html
new file mode 100644
index 0000000000000000000000000000000000000000..a7c27723834ccb4dd752c46263bbf9d42dffe5ab
--- /dev/null
+++ b/LayoutTests/fast/events/clipboard-dataTransferItemList-remove.html
@@ -0,0 +1,62 @@
+<!DOCTYPE html>
+<html>
+<head>
+<link rel="help" href="http://www.w3.org/TR/2013/WD-html51-20130528/editing.html#dom-datatransferitemlist-remove">
+<script src="../js/resources/js-test-pre.js"></script>
+</head>
+<body>
+<script>
+description("Checks that DataTransferItemList.remove() is working");
+
+var dataTansferItemList;
+function copy(event)
+{
+ debug("* copy event");
+ event.preventDefault();
haraken 2013/08/13 13:25:44 Nit: Why do you need preventDefault() in copy() bu
do-not-use 2013/08/13 13:51:21 I need preventDefault() in copy() because I am edi
+ dataTansferItemList = event.clipboardData.items;
+
+ dataTansferItemList.add('a', 'text/plain');
+ dataTansferItemList.add('http://www.google.com/', 'text/uri-list');
+ dataTansferItemList.add('<em>Markup</em>', 'text/html');
+ dataTansferItemList.add('hello world', 'custom-data');
+
+ shouldBe('dataTansferItemList.length', '4');
+ shouldBeEqualToString('dataTansferItemList[0].type', 'text/plain');
+ shouldBeEqualToString('dataTansferItemList[1].type', 'text/uri-list');
+ shouldBeEqualToString('dataTansferItemList[2].type', 'text/html');
+ shouldBeEqualToString('dataTansferItemList[3].type', 'custom-data');
+
+ // Failure cases.
+ shouldThrow('dataTansferItemList.remove()', '"TypeError: Not enough arguments"');
+ shouldNotThrow('dataTansferItemList.remove(-1)');
+ shouldBe('dataTansferItemList.length', '4');
+ shouldNotThrow('dataTansferItemList.remove(999)');
+ shouldBe('dataTansferItemList.length', '4');
+
+ // Success cases.
+ shouldNotThrow('dataTansferItemList.remove(0)');
+ shouldBe('dataTansferItemList.length', '3');
+ shouldBeEqualToString('dataTansferItemList[0].type', 'text/uri-list');
+ shouldBeEqualToString('dataTansferItemList[1].type', 'text/html');
+ shouldNotThrow('dataTansferItemList.remove(-4294967295)'); // Wraps to 1.
+ shouldBe('dataTansferItemList.length', '2');
+ shouldBeEqualToString('dataTansferItemList[1].type', 'custom-data');
+}
+
+function paste(event)
+{
+ debug("* paste event");
+ dataTansferItemList = event.clipboardData.items;
+ shouldBe('dataTansferItemList.length', '2');
+ shouldThrow('dataTansferItemList.remove(0)', '"InvalidStateError: An attempt was made to use an object that is not, or is no longer, usable."'); // List is readonly during paste.
+ shouldBe('dataTansferItemList.length', '2');
+}
+
+document.oncopy = copy;
+document.onpaste = paste;
+document.execCommand('copy');
+document.execCommand('paste');
+</script>
+<script src="../js/resources/js-test-post.js"></script>
+</body>
+</html>
« no previous file with comments | « no previous file | LayoutTests/fast/events/clipboard-dataTransferItemList-remove-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698