Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / events / constructors / media-key-event-constructor.html
blobc5686bc6c8000c2af1981401f0d900a9f66ab7b6
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <script src="../../../resources/js-test.js"></script>
5 </head>
7 <body>
8 <script>
10 window.jsTestIsAsync = true;
12 description("This tests the constructor for the MediaKeyEvent DOM class.");
14 function test()
16 debug("<br>*** No initializer passed ***");
17 shouldBe("new MediaKeyEvent('MediaKeyEvent').bubbles", "false");
18 shouldBe("new MediaKeyEvent('MediaKeyEvent').cancelable", "false");
19 shouldBeEmptyString("new MediaKeyEvent('MediaKeyEvent').keySystem");
20 shouldBeEmptyString("new MediaKeyEvent('MediaKeyEvent').sessionId");
21 shouldBeNull("new MediaKeyEvent('MediaKeyEvent').initData");
22 shouldBeNull("new MediaKeyEvent('MediaKeyEvent').message");
23 shouldBeEmptyString("new MediaKeyEvent('MediaKeyEvent').defaultURL");
24 shouldBeNull("new MediaKeyEvent('MediaKeyEvent').errorCode");
25 shouldBeZero("new MediaKeyEvent('MediaKeyEvent').systemCode");
27 debug("<br>*** Bubbles and cancelable true, other members are missing ***");
28 shouldBe("new MediaKeyEvent('MediaKeyEvent', { bubbles: true, cancelable: true }).bubbles", "true");
29 shouldBe("new MediaKeyEvent('MediaKeyEvent', { bubbles: true, cancelable: true }).cancelable", "true");
30 shouldBeEmptyString("new MediaKeyEvent('MediaKeyEvent', { bubbles: true, cancelable: true }).keySystem");
31 shouldBeEmptyString("new MediaKeyEvent('MediaKeyEvent', { bubbles: true, cancelable: true }).sessionId");
32 shouldBeNull("new MediaKeyEvent('MediaKeyEvent', { bubbles: true, cancelable: true }).initData");
33 shouldBeNull("new MediaKeyEvent('MediaKeyEvent', { bubbles: true, cancelable: true }).message");
34 shouldBeEmptyString("new MediaKeyEvent('MediaKeyEvent', { bubbles: true, cancelable: true }).defaultURL");
35 shouldBeNull("new MediaKeyEvent('MediaKeyEvent', { bubbles: true, cancelable: true }).errorCode");
36 shouldBeZero("new MediaKeyEvent('MediaKeyEvent', { bubbles: true, cancelable: true }).systemCode");
38 debug("<br>*** Bubbles and cancelable true, invalid other members ***");
39 shouldThrow("new MediaKeyEvent('MediaKeyEvent', { bubbles: true, cancelable: true, keySystem: undefined, sessionId: undefined, initData: Uint8Array, message: Uint8Array, defaultURL: undefined, errorCode: MediaKeyError, systemCode: undefined }).bubbles");
40 shouldThrow("new MediaKeyEvent('MediaKeyEvent', { bubbles: true, cancelable: true, keySystem: undefined, sessionId: undefined, initData: Uint8Array, message: Uint8Array, defaultURL: undefined, errorCode: MediaKeyError, systemCode: undefined }).cancelable");
41 shouldThrow("new MediaKeyEvent('MediaKeyEvent', { bubbles: true, cancelable: true, keySystem: undefined, sessionId: undefined, initData: Uint8Array, message: Uint8Array, defaultURL: undefined, errorCode: MediaKeyError, systemCode: undefined }).keySystem");
42 shouldThrow("new MediaKeyEvent('MediaKeyEvent', { bubbles: true, cancelable: true, keySystem: undefined, sessionId: undefined, initData: Uint8Array, message: Uint8Array, defaultURL: undefined, errorCode: MediaKeyError, systemCode: undefined }).sessionId");
43 shouldThrow("new MediaKeyEvent('MediaKeyEvent', { bubbles: true, cancelable: true, keySystem: undefined, sessionId: undefined, initData: Uint8Array, message: Uint8Array, defaultURL: undefined, errorCode: MediaKeyError, systemCode: undefined }).initData");
44 shouldThrow("new MediaKeyEvent('MediaKeyEvent', { bubbles: true, cancelable: true, keySystem: undefined, sessionId: undefined, initData: Uint8Array, message: Uint8Array, defaultURL: undefined, errorCode: MediaKeyError, systemCode: undefined }).message");
45 shouldThrow("new MediaKeyEvent('MediaKeyEvent', { bubbles: true, cancelable: true, keySystem: undefined, sessionId: undefined, initData: Uint8Array, message: Uint8Array, defaultURL: undefined, errorCode: MediaKeyError, systemCode: undefined }).defaultURL");
46 shouldThrow("new MediaKeyEvent('MediaKeyEvent', { bubbles: true, cancelable: true, keySystem: undefined, sessionId: undefined, initData: Uint8Array, message: Uint8Array, defaultURL: undefined, errorCode: MediaKeyError, systemCode: undefined }).errorCode");
47 shouldThrow("new MediaKeyEvent('MediaKeyEvent', { bubbles: true, cancelable: true, keySystem: undefined, sessionId: undefined, initData: Uint8Array, message: Uint8Array, defaultURL: undefined, errorCode: MediaKeyError, systemCode: undefined }).systemCode");
49 debug("<br>*** Initialize 'keySystem' with a invalid values ***");
50 emptyObject = { };
51 shouldBeEqualToString("new MediaKeyEvent('MediaKeyEvent', { keySystem: emptyObject }).keySystem", "[object Object]");
52 shouldBeEqualToString("new MediaKeyEvent('MediaKeyEvent', { keySystem: document }).keySystem", "[object HTMLDocument]");
54 debug("<br>*** Initialize 'sessionId' with a invalid values ***");
55 emptyObject = { };
56 shouldBeEqualToString("new MediaKeyEvent('MediaKeyEvent', { sessionId: emptyObject }).sessionId", "[object Object]");
57 shouldBeEqualToString("new MediaKeyEvent('MediaKeyEvent', { sessionId: document }).sessionId", "[object HTMLDocument]");
59 debug("<br>*** Initialize 'initData' with a invalid values ***");
60 shouldThrow("new MediaKeyEvent('MediaKeyEvent', { initData: 10 }).initData");
61 shouldThrow("new MediaKeyEvent('MediaKeyEvent', { initData: \'string\' }).initData");
62 emptyObject = { };
63 shouldThrow("new MediaKeyEvent('MediaKeyEvent', { initData: emptyObject }).initData");
64 shouldThrow("new MediaKeyEvent('MediaKeyEvent', { initData: document }).initData");
66 debug("<br>*** Initialize 'message' with a invalid values ***");
67 shouldThrow("new MediaKeyEvent('MediaKeyEvent', { message: 10 }).message");
68 shouldThrow("new MediaKeyEvent('MediaKeyEvent', { message: \'string\' }).message");
69 emptyObject = { };
70 shouldThrow("new MediaKeyEvent('MediaKeyEvent', { message: emptyObject }).message");
71 shouldThrow("new MediaKeyEvent('MediaKeyEvent', { message: document }).message");
73 debug("<br>*** Initialize 'defaultURL' with a invalid values ***");
74 emptyObject = { };
75 shouldBeEqualToString("new MediaKeyEvent('MediaKeyEvent', { defaultURL: emptyObject }).defaultURL", "[object Object]");
76 shouldBeEqualToString("new MediaKeyEvent('MediaKeyEvent', { defaultURL: document }).defaultURL", "[object HTMLDocument]");
78 debug("<br>*** Initialize 'errorCode' with a invalid values ***");
79 shouldThrow("new MediaKeyEvent('MediaKeyEvent', { errorCode: 10 }).errorCode");
80 shouldThrow("new MediaKeyEvent('MediaKeyEvent', { errorCode: \'string\' }).errorCode");
81 emptyObject = { };
82 shouldThrow("new MediaKeyEvent('MediaKeyEvent', { errorCode: emptyObject }).errorCode");
83 shouldThrow("new MediaKeyEvent('MediaKeyEvent', { errorCode: document }).errorCode");
85 debug("<br>*** Initialize 'systemCode' with a invalid values ***");
86 shouldBeZero("new MediaKeyEvent('MediaKeyEvent', { systemCode: \'string\' }).systemCode");
87 emptyObject = { };
88 shouldBeZero("new MediaKeyEvent('MediaKeyEvent', { systemCode: emptyObject }).systemCode");
89 shouldBeZero("new MediaKeyEvent('MediaKeyEvent', { systemCode: document }).systemCode");
91 debug("<br>*** Bubbles and cancelable true, valid other members ***");
92 shouldBe("new MediaKeyEvent('MediaKeyEvent', { bubbles: true, cancelable: true, keySystem: 'keySystem', sessionId: 'sessionId', initData: initDataArray, message: messageArray, defaultURL: 'defaultURL', errorCode: errorObject, systemCode: 123 }).bubbles", "true");
93 shouldBe("new MediaKeyEvent('MediaKeyEvent', { bubbles: true, cancelable: true, keySystem: 'keySystem', sessionId: 'sessionId', initData: initDataArray, message: messageArray, defaultURL: 'defaultURL', errorCode: errorObject, systemCode: 123 }).cancelable", "true");
94 shouldBeEqualToString("new MediaKeyEvent('MediaKeyEvent', { bubbles: true, cancelable: true, keySystem: 'keySystem', sessionId: 'sessionId', initData: initDataArray, message: messageArray, defaultURL: 'defaultURL', errorCode: errorObject, systemCode: 123 }).keySystem", "keySystem");
95 shouldBeEqualToString("new MediaKeyEvent('MediaKeyEvent', { bubbles: true, cancelable: true, keySystem: 'keySystem', sessionId: 'sessionId', initData: initDataArray, message: messageArray, defaultURL: 'defaultURL', errorCode: errorObject, systemCode: 123 }).sessionId", "sessionId");
96 shouldBe("new MediaKeyEvent('MediaKeyEvent', { bubbles: true, cancelable: true, keySystem: 'keySystem', sessionId: 'sessionId', initData: initDataArray, message: messageArray, defaultURL: 'defaultURL', errorCode: errorObject, systemCode: 123 }).initData", "initDataArray");
97 shouldBe("new MediaKeyEvent('MediaKeyEvent', { bubbles: true, cancelable: true, keySystem: 'keySystem', sessionId: 'sessionId', initData: initDataArray, message: messageArray, defaultURL: 'defaultURL', errorCode: errorObject, systemCode: 123 }).message", "messageArray");
98 shouldBeEqualToString("new MediaKeyEvent('MediaKeyEvent', { bubbles: true, cancelable: true, keySystem: 'keySystem', sessionId: 'sessionId', initData: initDataArray, message: messageArray, defaultURL: 'defaultURL', errorCode: errorObject, systemCode: 123 }).defaultURL", "defaultURL");
99 // FIXME(82988): These two fail.
100 shouldBeNonNull("new MediaKeyEvent('MediaKeyEvent', { bubbles: true, cancelable: true, keySystem: 'keySystem', sessionId: 'sessionId', initData: initDataArray, message: messageArray, defaultURL: 'defaultURL', errorCode: errorObject, systemCode: 123 }).errorCode");
101 shouldBe("new MediaKeyEvent('MediaKeyEvent', { bubbles: true, cancelable: true, keySystem: 'keySystem', sessionId: 'sessionId', initData: initDataArray, message: messageArray, defaultURL: 'defaultURL', errorCode: errorObject, systemCode: 123 }).errorCode.code", "MediaKeyError.MEDIA_KEYERR_UNKNOWN");
102 shouldBe("new MediaKeyEvent('MediaKeyEvent', { bubbles: true, cancelable: true, keySystem: 'keySystem', sessionId: 'sessionId', initData: initDataArray, message: messageArray, defaultURL: 'defaultURL', errorCode: errorObject, systemCode: 123 }).systemCode", "123");
104 debug("<br>*** Initialize with valid members ***");
105 shouldBe("new MediaKeyEvent('MediaKeyEvent', { keySystem: 'keySystem', sessionId: 'sessionId', initData: initDataArray, message: messageArray, defaultURL: 'defaultURL', errorCode: errorObject, systemCode: 123 }).bubbles", "true");
106 shouldBe("new MediaKeyEvent('MediaKeyEvent', { keySystem: 'keySystem', sessionId: 'sessionId', initData: initDataArray, message: messageArray, defaultURL: 'defaultURL', errorCode: errorObject, systemCode: 123 }).cancelable", "true");
107 shouldBeEqualToString("new MediaKeyEvent('MediaKeyEvent', { keySystem: 'keySystem', sessionId: 'sessionId', initData: initDataArray, message: messageArray, defaultURL: 'defaultURL', errorCode: errorObject, systemCode: 123 }).keySystem", "keySystem");
108 shouldBeEqualToString("new MediaKeyEvent('MediaKeyEvent', { keySystem: 'keySystem', sessionId: 'sessionId', initData: initDataArray, message: messageArray, defaultURL: 'defaultURL', errorCode: errorObject, systemCode: 123 }).sessionId", "sessionId");
109 shouldBe("new MediaKeyEvent('MediaKeyEvent', { keySystem: 'keySystem', sessionId: 'sessionId', initData: initDataArray, message: messageArray, defaultURL: 'defaultURL', errorCode: errorObject, systemCode: 123 }).initData", "initDataArray");
110 shouldBe("new MediaKeyEvent('MediaKeyEvent', { keySystem: 'keySystem', sessionId: 'sessionId', initData: initDataArray, message: messageArray, defaultURL: 'defaultURL', errorCode: errorObject, systemCode: 123 }).message", "messageArray");
111 shouldBeEqualToString("new MediaKeyEvent('MediaKeyEvent', { keySystem: 'keySystem', sessionId: 'sessionId', initData: initDataArray, message: messageArray, defaultURL: 'defaultURL', errorCode: errorObject, systemCode: 123 }).defaultURL", "defaultURL");
112 // FIXME(82988): These two fail.
113 shouldBeNonNull("new MediaKeyEvent('MediaKeyEvent', { keySystem: 'keySystem', sessionId: 'sessionId', initData: initDataArray, message: messageArray, defaultURL: 'defaultURL', errorCode: errorObject, systemCode: 123 }).errorCode");
114 shouldBe("new MediaKeyEvent('MediaKeyEvent', { keySystem: 'keySystem', sessionId: 'sessionId', initData: initDataArray, message: messageArray, defaultURL: 'defaultURL', errorCode: errorObject, systemCode: 123 }).errorCode.code", "MediaKeyError.MEDIA_KEYERR_UNKNOWN");
115 shouldBe("new MediaKeyEvent('MediaKeyEvent', { keySystem: 'keySystem', sessionId: 'sessionId', initData: initDataArray, message: messageArray, defaultURL: 'defaultURL', errorCode: errorObject, systemCode: 123 }).systemCode", "123");
117 debug("");
118 finishJSTest();
121 var initDataArray = new Uint8Array([0x41, 0x42, 0x43]);
122 var messageArray = new Uint8Array([0x51, 0x52, 0x53]);
123 // FIXME(82988): This does not create an error like we want.
124 //var errorObject = window.MediaKeyError;
125 var errorObject = null;
126 // shouldBe("typeof errorObject", TBD);
128 video = document.createElement('video');
129 document.body.appendChild(video);
131 test()
132 </script>
134 </body>
135 </html>