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

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

Issue 443053002: Add support for RelatedEvent. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Done Created 6 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/constructors/related-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/related-event-constructor.html
diff --git a/LayoutTests/fast/events/constructors/related-event-constructor.html b/LayoutTests/fast/events/constructors/related-event-constructor.html
new file mode 100644
index 0000000000000000000000000000000000000000..726d66d74d5f162e05b4bf0692c4aedd124f6ec2
--- /dev/null
+++ b/LayoutTests/fast/events/constructors/related-event-constructor.html
@@ -0,0 +1,56 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="../../../resources/js-test.js"></script>
+</head>
+<body>
+<script>
+
+description("This tests the constructor for the RelatedEvent DOM class.");
+
+var testObject = {nyannyan: 123};
+var testDiv = document.createElement("div");
+
+// No initializer is passed.
+shouldBeFalse("new RelatedEvent('eventType').bubbles");
+shouldBeFalse("new RelatedEvent('eventType').cancelable");
+shouldBeNull("new RelatedEvent('eventType').relatedTarget");
+
+// bubbles is passed.
+shouldBeFalse("new RelatedEvent('eventType', { bubbles: false }).bubbles");
+shouldBeTrue("new RelatedEvent('eventType', { bubbles: true }).bubbles");
+
+// cancelable is passed.
+shouldBeFalse("new RelatedEvent('eventType', { cancelable: false }).cancelable");
+shouldBeTrue("new RelatedEvent('eventType', { cancelable: true }).cancelable");
+
+// relatedTarget is passed.
+// Valid objects.
+shouldBe("new RelatedEvent('eventType', { relatedTarget: testDiv }).relatedTarget", "testDiv");
+shouldBe("new RelatedEvent('eventType', { relatedTarget: document }).relatedTarget", "document");
+shouldBe("new RelatedEvent('eventType', { relatedTarget: window }).relatedTarget", "window");
+
+// Invalid objects.
+shouldThrow("new RelatedEvent('eventType', { relatedTarget: testObject }).relatedTarget");
+shouldBeNull("new RelatedEvent('eventType', { relatedTarget: undefined }).relatedTarget", "null");
+shouldBeNull("new RelatedEvent('eventType', { relatedTarget: null }).relatedTarget", "null");
+shouldThrow("new RelatedEvent('eventType', { relatedTarget: false }).relatedTarget");
+shouldThrow("new RelatedEvent('eventType', { relatedTarget: true }).relatedTarget");
+shouldThrow("new RelatedEvent('eventType', { relatedTarget: '' }).relatedTarget");
+shouldThrow("new RelatedEvent('eventType', { relatedTarget: 'chocolate' }).relatedTarget");
+shouldThrow("new RelatedEvent('eventType', { relatedTarget: 12345 }).relatedTarget");
+shouldThrow("new RelatedEvent('eventType', { relatedTarget: 18446744073709551615 }).relatedTarget");
+shouldThrow("new RelatedEvent('eventType', { relatedTarget: NaN }).relatedTarget");
+// Note that valueOf() is not called, when the left hand side is evaluated.
+shouldThrow("new RelatedEvent('eventType', { relatedTarget: {valueOf: function () { return testDiv; } } }).relatedTarget == testDiv");
+shouldBeTrue("new RelatedEvent('eventType', { get relatedTarget() { return testDiv; } }).relatedTarget == testDiv");
+shouldThrow("new RelatedEvent('eventType', { get relatedTarget() { return 123; } }).relatedTarget");
+shouldThrow("new RelatedEvent('eventType', { get relatedTarget() { throw 'RelatedEvent Error'; } })");
+
+// All initializers are passed.
+shouldBeTrue("new RelatedEvent('eventType', { bubbles: true, cancelable: true, relatedTarget: testDiv }).bubbles", "true");
+shouldBeTrue("new RelatedEvent('eventType', { bubbles: true, cancelable: true, relatedTarget: testDiv }).cancelable", "true");
+shouldBe("new RelatedEvent('eventType', { bubbles: true, cancelable: true, relatedTarget: testDiv }).relatedTarget", "testDiv");
+</script>
+</body>
+</html>
« no previous file with comments | « no previous file | LayoutTests/fast/events/constructors/related-event-constructor-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698