OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <html> |
| 3 <head> |
| 4 <script src="../../../resources/js-test.js"></script> |
| 5 </head> |
| 6 <body> |
| 7 <script> |
| 8 |
| 9 description("This tests the constructor for the RelatedEvent DOM class."); |
| 10 |
| 11 var testObject = {nyannyan: 123}; |
| 12 var testDiv = document.createElement("div"); |
| 13 |
| 14 // No initializer is passed. |
| 15 shouldBe("new RelatedEvent('eventType').bubbles", "false"); |
| 16 shouldBe("new RelatedEvent('eventType').cancelable", "false"); |
| 17 shouldBe("new RelatedEvent('eventType').relatedTarget", "null"); |
| 18 |
| 19 // bubbles is passed. |
| 20 shouldBe("new RelatedEvent('eventType', { bubbles: false }).bubbles", "false"); |
| 21 shouldBe("new RelatedEvent('eventType', { bubbles: true }).bubbles", "true"); |
| 22 |
| 23 // cancelable is passed. |
| 24 shouldBe("new RelatedEvent('eventType', { cancelable: false }).cancelable", "fal
se"); |
| 25 shouldBe("new RelatedEvent('eventType', { cancelable: true }).cancelable", "true
"); |
| 26 |
| 27 // relatedTarget is passed. |
| 28 // Valid objects. |
| 29 shouldBe("new RelatedEvent('eventType', { relatedTarget: testDiv }).relatedTarge
t", "testDiv"); |
| 30 shouldBe("new RelatedEvent('eventType', { relatedTarget: document }).relatedTarg
et", "document"); |
| 31 shouldBe("new RelatedEvent('eventType', { relatedTarget: window }).relatedTarget
", "window"); |
| 32 |
| 33 // Invalid objects. |
| 34 shouldThrow("new RelatedEvent('eventType', { relatedTarget: testObject }).relate
dTarget"); |
| 35 shouldBe("new RelatedEvent('eventType', { relatedTarget: undefined }).relatedTar
get", "null"); |
| 36 shouldBe("new RelatedEvent('eventType', { relatedTarget: null }).relatedTarget",
"null"); |
| 37 shouldThrow("new RelatedEvent('eventType', { relatedTarget: false }).relatedTarg
et"); |
| 38 shouldThrow("new RelatedEvent('eventType', { relatedTarget: true }).relatedTarge
t"); |
| 39 shouldThrow("new RelatedEvent('eventType', { relatedTarget: '' }).relatedTarget"
); |
| 40 shouldThrow("new RelatedEvent('eventType', { relatedTarget: 'chocolate' }).relat
edTarget"); |
| 41 shouldThrow("new RelatedEvent('eventType', { relatedTarget: 12345 }).relatedTarg
et"); |
| 42 shouldThrow("new RelatedEvent('eventType', { relatedTarget: 18446744073709551615
}).relatedTarget"); |
| 43 shouldThrow("new RelatedEvent('eventType', { relatedTarget: NaN }).relatedTarget
"); |
| 44 // Note that valueOf() is not called, when the left hand side is evaluated. |
| 45 shouldThrow("new RelatedEvent('eventType', { relatedTarget: {valueOf: function (
) { return testDiv; } } }).relatedTarget == testDiv"); |
| 46 shouldBeTrue("new RelatedEvent('eventType', { get relatedTarget() { return testD
iv; } }).relatedTarget == testDiv"); |
| 47 shouldThrow("new RelatedEvent('eventType', { get relatedTarget() { return 123; }
}).relatedTarget"); |
| 48 shouldThrow("new RelatedEvent('eventType', { get relatedTarget() { throw 'Relate
dEvent Error'; } })"); |
| 49 |
| 50 // All initializers are passed. |
| 51 shouldBe("new RelatedEvent('eventType', { bubbles: true, cancelable: true, relat
edTarget: testDiv }).bubbles", "true"); |
| 52 shouldBe("new RelatedEvent('eventType', { bubbles: true, cancelable: true, relat
edTarget: testDiv }).cancelable", "true"); |
| 53 shouldBe("new RelatedEvent('eventType', { bubbles: true, cancelable: true, relat
edTarget: testDiv }).relatedTarget", "testDiv"); |
| 54 </script> |
| 55 </body> |
| 56 </html> |
OLD | NEW |