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> |