OLD | NEW |
| (Empty) |
1 importScripts("/resources/testharness.js"); | |
2 | |
3 test(function() { | |
4 self.onmessage = 1; | |
5 assert_equals(self.onmessage, null, | |
6 "attribute should return null after being set to a primitive"); | |
7 }, "Setting onmessage to 1"); | |
8 | |
9 test(function() { | |
10 var object = { | |
11 handleEvent: this.unreached_func() | |
12 }; | |
13 self.onmessage = object; | |
14 assert_equals(self.onmessage, object, | |
15 "attribute should return the object it was set to."); | |
16 | |
17 self.dispatchEvent(new Event("message")); | |
18 }, "Setting onmessage to an object"); | |
19 | |
20 test(function() { | |
21 var triggered = false; | |
22 var f = function(e) { triggered = true; }; | |
23 self.onmessage = f; | |
24 assert_equals(self.onmessage, f, | |
25 "attribute should return the function it was set to."); | |
26 | |
27 self.dispatchEvent(new Event("message")); | |
28 assert_true(triggered, "event handler should have been triggered"); | |
29 }, "Setting onmessage to a function"); | |
30 | |
31 | |
32 test(function() { | |
33 assert_not_equals(self.onmessage, null, | |
34 "attribute should not return null after being set to a funct
ion"); | |
35 self.onmessage = 1; | |
36 assert_equals(self.onmessage, null, | |
37 "attribute should return null after being set to a primitive"); | |
38 }, "Setting onmessage to 1 (again)"); | |
39 | |
40 done(); | |
OLD | NEW |