Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / media / encrypted-media / prefixed / encrypted-media-syntax.html
blob80004c1d10ab2813c96a1c69865d734d8bdf0e4e
1 <!doctype html>
2 <html lang="en">
3 <head>
4 </head>
5 <body>
6 <video></video>
7 <p>Tests invalid and valid syntaxes.</p>
9 <script src=../../media-file.js></script>
10 <script src=../../video-test.js></script>
11 <script>
12 var initData = new Uint8Array([0x51, 0x52, 0x53]);
13 var key = initData;
15 function loadStarted()
17 consoleWrite("Verify valid syntaxes do not throw.");
18 testExpected("video.networkState", video.NETWORK_LOADING);
19 testExpected("video.currentSrc", "", "!=");
20 run("video.webkitGenerateKeyRequest('webkit-org.w3.clearkey')");
21 run("video.webkitGenerateKeyRequest('webkit-org.w3.clearkey', initData)");
22 run("video.webkitAddKey('webkit-org.w3.clearkey', key)");
23 run("video.webkitAddKey('webkit-org.w3.clearkey', key, 'session')");
24 run("video.webkitAddKey('webkit-org.w3.clearkey', key, initData)");
25 run("video.webkitAddKey('webkit-org.w3.clearkey', key, initData, 'session')");
26 run("video.webkitCancelKeyRequest('webkit-org.w3.clearkey')");
27 run("video.webkitCancelKeyRequest('webkit-org.w3.clearkey', 'session')");
29 consoleWrite("<br>Unsupported key systems result in NOT_SUPPORTED_ERR.");
30 testDOMException("video.webkitGenerateKeyRequest('com.example.invalid')", "DOMException.NOT_SUPPORTED_ERR");
31 testDOMException("video.webkitAddKey('com.example.invalid', key)", "DOMException.NOT_SUPPORTED_ERR");
32 testDOMException("video.webkitCancelKeyRequest('com.example.invalid')", "DOMException.NOT_SUPPORTED_ERR");
34 endTest();
37 consoleWrite("Test calling functions with too few parameters.");
38 testException("video.webkitGenerateKeyRequest()", '"TypeError: Failed to execute \'webkitGenerateKeyRequest\' on \'HTMLMediaElement\': 1 argument required, but only 0 present."');
39 testException("video.webkitAddKey()", '"TypeError: Failed to execute \'webkitAddKey\' on \'HTMLMediaElement\': 2 arguments required, but only 0 present."');
40 testException("video.webkitAddKey('webkit-org.w3.clearkey')", '"TypeError: Failed to execute \'webkitAddKey\' on \'HTMLMediaElement\': 2 arguments required, but only 1 present."');
41 testException("video.webkitCancelKeyRequest()", '"TypeError: Failed to execute \'webkitCancelKeyRequest\' on \'HTMLMediaElement\': 1 argument required, but only 0 present."');
43 consoleWrite("<br>Verify invalid key system parameter is caught before checking whether loading has started.");
44 // If the above was not the case, all of these would be INVALID_STATE_ERR.
45 // Also tests "null" case for first parameter.
46 testExpected("video.networkState", video.NETWORK_EMPTY);
47 testExpected("video.currentSrc", "");
48 testDOMException("video.webkitGenerateKeyRequest('')", "DOMException.SYNTAX_ERR");
49 testDOMException("video.webkitGenerateKeyRequest(null)", "DOMException.SYNTAX_ERR");
50 testDOMException("video.webkitGenerateKeyRequest(undefined)", "DOMException.SYNTAX_ERR");
51 testDOMException("video.webkitAddKey('', key)", "DOMException.SYNTAX_ERR");
52 testDOMException("video.webkitAddKey(null, key)", "DOMException.SYNTAX_ERR");
53 testDOMException("video.webkitAddKey(undefined, key)", "DOMException.SYNTAX_ERR");
54 testDOMException("video.webkitCancelKeyRequest('')", "DOMException.SYNTAX_ERR");
55 testDOMException("video.webkitCancelKeyRequest(null)", "DOMException.SYNTAX_ERR");
56 testDOMException("video.webkitCancelKeyRequest(undefined)", "DOMException.SYNTAX_ERR");
58 consoleWrite("<br>null key is caught before load state is checked.");
59 testDOMException("video.webkitAddKey('webkit-org.w3.clearkey', '')", "DOMException.SYNTAX_ERR");
60 testDOMException("video.webkitAddKey('webkit-org.w3.clearkey', null)", "DOMException.SYNTAX_ERR");
61 testDOMException("video.webkitAddKey('webkit-org.w3.clearkey', undefined)", "DOMException.SYNTAX_ERR");
63 consoleWrite("<br>0-length key is caught before load state is checked.");
64 testDOMException("video.webkitAddKey('webkit-org.w3.clearkey', new Uint8Array())", "DOMException.TYPE_MISMATCH_ERR");
66 consoleWrite("<br>Key system validity is not checked before loading.");
67 testDOMException("video.webkitGenerateKeyRequest('com.example.invalid')", "DOMException.INVALID_STATE_ERR");
68 testDOMException("video.webkitAddKey('com.example.invalid', key)", "DOMException.INVALID_STATE_ERR");
69 testDOMException("video.webkitCancelKeyRequest('com.example.invalid')", "DOMException.INVALID_STATE_ERR");
71 // FIXME(82952): Add "test-encrypted" file.
72 video.setAttribute("src", findMediaFile("video", "../../content/test"));
73 consoleWrite("");
74 waitForEvent('loadstart', loadStarted);
75 </script>
76 </body>
77 </html>