| <!DOCTYPE html> |
| <html> |
| <head> |
| <script src="../../../resources/js-test-pre.js"></script> |
| </head> |
| <body> |
| <script> |
| |
| description("This tests the constructor for the MediaStreamEvent DOM class."); |
| |
| var testObject = {nyannyan: 123}; |
| var mediaStream = new MediaStream(); |
| |
| // No initializer is passed. |
| shouldBe("new MediaStreamEvent('eventType').bubbles", "false"); |
| shouldBe("new MediaStreamEvent('eventType').cancelable", "false"); |
| shouldBe("new MediaStreamEvent('eventType').stream", "null"); |
| |
| // bubbles is passed. |
| shouldBe("new MediaStreamEvent('eventType', { bubbles: false }).bubbles", "false"); |
| shouldBe("new MediaStreamEvent('eventType', { bubbles: true }).bubbles", "true"); |
| |
| // cancelable is passed. |
| shouldBe("new MediaStreamEvent('eventType', { cancelable: false }).cancelable", "false"); |
| shouldBe("new MediaStreamEvent('eventType', { cancelable: true }).cancelable", "true"); |
| |
| // stream is passed. |
| // Valid object. |
| shouldBe("new MediaStreamEvent('eventType', { stream: mediaStream }).stream", "mediaStream"); |
| |
| // Invalid objects. |
| shouldThrowErrorName("new MediaStreamEvent('eventType', { stream: testObject }).stream", "TypeError"); |
| shouldThrowErrorName("new MediaStreamEvent('eventType', { stream: document }).stream", "TypeError"); |
| shouldBe("new MediaStreamEvent('eventType', { stream: undefined }).stream", "null"); |
| shouldBe("new MediaStreamEvent('eventType', { stream: null }).stream", "null"); |
| shouldThrowErrorName("new MediaStreamEvent('eventType', { stream: false }).stream", "TypeError"); |
| shouldThrowErrorName("new MediaStreamEvent('eventType', { stream: true }).stream", "TypeError"); |
| shouldThrowErrorName("new MediaStreamEvent('eventType', { stream: '' }).stream", "TypeError"); |
| shouldThrowErrorName("new MediaStreamEvent('eventType', { stream: 'chocolate' }).stream", "TypeError"); |
| shouldThrowErrorName("new MediaStreamEvent('eventType', { stream: 12345 }).stream", "TypeError"); |
| shouldThrowErrorName("new MediaStreamEvent('eventType', { stream: 18446744073709551615 }).stream", "TypeError"); |
| shouldThrowErrorName("new MediaStreamEvent('eventType', { stream: NaN }).stream", "TypeError"); |
| // Note that valueOf() is not called, when the left hand side is evaluated. |
| shouldThrowErrorName("new MediaStreamEvent('eventType', { stream: {valueOf: function () { return mediaStream; } } }).stream", "TypeError"); |
| shouldThrowErrorName("new MediaStreamEvent('eventType', { get stream() { return 123; } }).stream", "TypeError"); |
| shouldThrow("new MediaStreamEvent('eventType', { get stream() { throw 'MediaStreamEvent Error'; } })"); |
| |
| // All initializers are passed. |
| shouldBe("new MediaStreamEvent('eventType', { bubbles: true, cancelable: true, stream: mediaStream }).bubbles", "true"); |
| shouldBe("new MediaStreamEvent('eventType', { bubbles: true, cancelable: true, stream: mediaStream }).cancelable", "true"); |
| shouldBe("new MediaStreamEvent('eventType', { bubbles: true, cancelable: true, stream: mediaStream }).stream", "mediaStream"); |
| </script> |
| <script src="../../../resources/js-test-post.js"></script> |
| </body> |
| </html> |