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

Unified Diff: third_party/WebKit/LayoutTests/imported/wpt/workers/interfaces/DedicatedWorkerGlobalScope/onmessage.worker.js

Issue 2418853003: Worker: Import "imported/wpt/workers" tests (Retry) (Closed)
Patch Set: rebase Created 4 years, 2 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
Index: third_party/WebKit/LayoutTests/imported/wpt/workers/interfaces/DedicatedWorkerGlobalScope/onmessage.worker.js
diff --git a/third_party/WebKit/LayoutTests/imported/wpt/workers/interfaces/DedicatedWorkerGlobalScope/onmessage.worker.js b/third_party/WebKit/LayoutTests/imported/wpt/workers/interfaces/DedicatedWorkerGlobalScope/onmessage.worker.js
new file mode 100644
index 0000000000000000000000000000000000000000..6f285caac38574ca95cd634e014ca444f246bf73
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/imported/wpt/workers/interfaces/DedicatedWorkerGlobalScope/onmessage.worker.js
@@ -0,0 +1,40 @@
+importScripts("/resources/testharness.js");
+
+test(function() {
+ self.onmessage = 1;
+ assert_equals(self.onmessage, null,
+ "attribute should return null after being set to a primitive");
+}, "Setting onmessage to 1");
+
+test(function() {
+ var object = {
+ handleEvent: this.unreached_func()
+ };
+ self.onmessage = object;
+ assert_equals(self.onmessage, object,
+ "attribute should return the object it was set to.");
+
+ self.dispatchEvent(new Event("message"));
+}, "Setting onmessage to an object");
+
+test(function() {
+ var triggered = false;
+ var f = function(e) { triggered = true; };
+ self.onmessage = f;
+ assert_equals(self.onmessage, f,
+ "attribute should return the function it was set to.");
+
+ self.dispatchEvent(new Event("message"));
+ assert_true(triggered, "event handler should have been triggered");
+}, "Setting onmessage to a function");
+
+
+test(function() {
+ assert_not_equals(self.onmessage, null,
+ "attribute should not return null after being set to a function");
+ self.onmessage = 1;
+ assert_equals(self.onmessage, null,
+ "attribute should return null after being set to a primitive");
+}, "Setting onmessage to 1 (again)");
+
+done();

Powered by Google App Engine
This is Rietveld 408576698