Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(36)

Unified Diff: LayoutTests/media/encrypted-media/encrypted-media-v2-syntax.html

Issue 182453005: Encrypted Media: Convert unprefixed syntax layout test to use testharness.js. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | LayoutTests/media/encrypted-media/encrypted-media-v2-syntax-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: LayoutTests/media/encrypted-media/encrypted-media-v2-syntax.html
diff --git a/LayoutTests/media/encrypted-media/encrypted-media-v2-syntax.html b/LayoutTests/media/encrypted-media/encrypted-media-v2-syntax.html
index 89ae7e69f2c8fd65198bcef4ca2ccbe6f13b13b2..ce917639b17862631e0d3a670f63fd7a072ff882 100644
--- a/LayoutTests/media/encrypted-media/encrypted-media-v2-syntax.html
+++ b/LayoutTests/media/encrypted-media/encrypted-media-v2-syntax.html
@@ -1,70 +1,116 @@
<!DOCTYPE html>
ddorwin 2014/03/07 01:45:51 We'll need to rename this file in a future CL.
xhwang 2014/03/08 00:37:45 okay.
<html>
<head>
- <title>MediaKeys</title>
- <script src=../video-test.js></script>
+ <title>Test unprefixed EME syntax</title>
ddorwin 2014/03/07 01:45:51 "unprefixed " should be removed. This would be irr
xhwang 2014/03/08 00:37:45 Done.
+ <script src="encrypted-media-utils.js"></script>
+ <script src="../../resources/testharness.js"></script>
+ <script src="../../resources/testharnessreport.js"></script>
+
ddorwin 2014/03/07 01:45:51 empty line
xhwang 2014/03/08 00:37:45 Done.
+ </head>
+ <body>
+ <div id="log"></div>
<script>
- function stringToUint8Array(str)
+ var typeError = new TypeError();
+ var mediaKeys = null;
+ var mediaKeySession = null;
+ var initData = stringToUint8Array('mock');
ddorwin 2014/03/07 01:45:51 FWIW, 'mock' is left over from when there was a mo
xhwang 2014/03/08 00:37:45 Done.
+ var extraParam = 'extra parameter';
+
+ function test_syntax(func, params, exception, description)
ddorwin 2014/03/07 01:45:51 test_invalid_syntax? It's not possible to test val
xhwang 2014/03/08 00:37:45 I am not sure. I was following media source tests.
{
- var arr=[];
- for(var i=0,j=str.length;i<j;++i)
- arr[i]=str.charCodeAt(i);
- return new Uint8Array(arr);
- }
+ for (var i = 0; i < params.length; ++i) {
+ test(function()
+ {
+ assert_throws(exception, function() { func.apply(this, params[i]); });
+ }, description + ": '" + params[i].join("', '") + "'.");
ddorwin 2014/03/07 01:45:51 missing the function name?
xhwang 2014/03/08 00:37:45 The name is optional. I skip it because I don't se
+ }
+ };
- var mediaKeys;
- var mediaKeySession;
- var initData = stringToUint8Array('mock');
+ // Not using test_syntax() because there's no easy way to bind a
+ // constructor to a function.
+ test(function()
+ {
+ assert_throws(typeError, function() { new MediaKeys(); });
+ assert_throws("INVALID_ACCESS_ERR", function() { new MediaKeys(""); });
+ assert_throws("NOT_SUPPORTED_ERR", function() { new MediaKeys(null); });
+ assert_throws("NOT_SUPPORTED_ERR", function() { new MediaKeys(undefined); });
+ assert_throws("NOT_SUPPORTED_ERR", function() { new MediaKeys("unsupported"); });
ddorwin 2014/03/07 01:45:51 This isn't really a syntax test (nor I guess are n
xhwang 2014/03/08 00:37:45 "null" may also not be testing syntax :) Also, it'
ddorwin 2014/03/10 20:11:44 Let's look at what they _should_ throw, but note t
+ }, "Test MediaKeys constructor exceptions.");
- function checkError()
+ test(function()
{
- testExpected('mediaKeySession.error', null, '!=');
- testExpected('mediaKeySession.error.code', MediaKeyError.MEDIA_KEYERR_UNKNOWN);
- testExpected('mediaKeySession.error.systemCode', 0);
- }
+ assert_equals(typeof window.MediaKeys, "function");
+ mediaKeys = new MediaKeys("org.w3.clearkey");
+ mediaKeys = new MediaKeys("org.w3.clearkey", extraParam);
ddorwin 2014/03/07 01:45:51 s/extraParam/"extra"? Do we need a variable?
xhwang 2014/03/08 00:37:45 Done.
+ assert_equals(typeof mediaKeys, 'object');
+ assert_equals(mediaKeys.keySystem, 'org.w3.clearkey');
+ assert_equals(typeof mediaKeys.createSession, 'function');
+ }, "Test MediaKeys constructor.");
- function runTest()
+ test_syntax(mediaKeys.createSession.bind(mediaKeys), [
+ [],
ddorwin 2014/03/07 01:45:51 Is this much more readable than l33-37? Especially
xhwang 2014/03/08 00:37:45 Done.
+ [''],
+ [null],
+ [undefined],
+ ['video/webm'],
+ [new Uint8Array(0)],
+ [initData],
+ ], typeError, 'Test MediaKeys createSession() type errors');
ddorwin 2014/03/07 01:45:51 "too few parameters"?
xhwang 2014/03/08 00:37:45 Added comments.
+
+ test_syntax(mediaKeys.createSession.bind(mediaKeys), [
+ ['video/webm', ''],
+ ['video/webm', null],
+ ['video/webm', undefined],
+ ['video/webm', new Uint8Array(0)],
ddorwin 2014/03/07 01:45:51 We should test normal arrays, objects, numbers, et
xhwang 2014/03/08 00:37:45 Done.
ddorwin 2014/03/10 20:11:44 As mentioned at new line 22, I don't think we are
+ ['', initData],
+ ], 'InvalidAccessError', 'Test MediaKeys createSession() invalid access errors');
ddorwin 2014/03/07 01:45:51 Except for the last one, these are really empty ar
xhwang 2014/03/08 00:37:45 Done.
+
+ test_syntax(mediaKeys.createSession.bind(mediaKeys), [
+ [null, initData],
+ [undefined, initData],
+ ["unsupported", initData],
+ ["Video/webm", initData],
+ ], 'NotSupportedError', 'Test MediaKeys createSession() not supported errors');
+
ddorwin 2014/03/07 01:45:51 Should we have a basic isTypeSupported() syntax te
xhwang 2014/03/08 00:37:45 Yeah, will do.
+ test(function()
{
- consoleWrite("Test MediaKeys.");
- testExpected('typeof window.MediaKeys', 'function');
- testDOMException('new MediaKeys("")', "DOMException.INVALID_ACCESS_ERR");
- testDOMException('new MediaKeys("unsupported")', "DOMException.NOT_SUPPORTED_ERR");
- run('mediaKeys = new MediaKeys("org.w3.clearkey")');
- testExpected('typeof mediaKeys', 'object');
- testExpected('mediaKeys.keySystem', 'org.w3.clearkey');
- testExpected('typeof mediaKeys.createSession', 'function');
+ mediaKeySession = mediaKeys.createSession('video/webm', initData);
+ mediaKeySession = mediaKeys.createSession('video/webm', initData, extraParam);
+ assert_equals(typeof mediaKeySession, 'object');
+ assert_equals(typeof mediaKeySession.addEventListener, 'function');
ddorwin 2014/03/07 01:45:51 Should check MK does not have this.
xhwang 2014/03/08 00:37:45 Done.
+ assert_equals(typeof mediaKeySession.update, 'function');
+ assert_equals(mediaKeySession.error, null);
+ assert_equals(mediaKeySession.keySystem, 'org.w3.clearkey');
+ assert_not_equals(mediaKeySession.sessionId, null);
ddorwin 2014/03/07 01:45:51 Can we actually verify it's a string and not empty
xhwang 2014/03/08 00:37:45 We need to wait for the "ready" if we want to chec
+ assert_equals(mediaKeySession.onwebkitkeyadded, undefined);
ddorwin 2014/03/07 01:45:51 Is this useful? Maybe we should test that none of
xhwang 2014/03/08 00:37:45 Removed.
+ assert_equals(mediaKeySession.onwebkitkeyerror, undefined);
ddorwin 2014/03/07 01:45:51 speaking of which, we should have HTMLMediaElement
xhwang 2014/03/08 00:37:45 Added FIXME.
+ assert_equals(mediaKeySession.onwebkitkeymessage, undefined);
+ }, "Test MediaKeySession creation.");
- testException('mediaKeys.createSession()', '"TypeError: Failed to execute \'createSession\' on \'MediaKeys\': 2 arguments required, but only 0 present."');
- testException('mediaKeys.createSession("")', '"TypeError: Failed to execute \'createSession\' on \'MediaKeys\': 2 arguments required, but only 1 present."');
- testException('mediaKeys.createSession("video/webm")', '"TypeError: Failed to execute \'createSession\' on \'MediaKeys\': 2 arguments required, but only 1 present."');
- testDOMException('mediaKeys.createSession("", new Uint8Array(1))', "DOMException.INVALID_ACCESS_ERR");
- testDOMException('mediaKeys.createSession("video/webm", null)', "DOMException.INVALID_ACCESS_ERR");
- testDOMException('mediaKeys.createSession("video/webm", new Uint8Array(0))', "DOMException.INVALID_ACCESS_ERR");
- testDOMException('mediaKeys.createSession("unsupported/type", new Uint8Array(1))', "DOMException.NOT_SUPPORTED_ERR");
- consoleWrite("");
+ test_syntax(mediaKeySession.update.bind(mediaKeySession), [
+ [],
+ ], typeError, 'Test MediaKeySession update() type errors');
ddorwin 2014/03/07 01:45:51 too few parameters
xhwang 2014/03/08 00:37:45 Done.
ddorwin 2014/03/07 01:45:51 Looking at base, I see we lose some verbosity. Goo
xhwang 2014/03/08 00:37:45 Added some comments. Do we need to have descriptio
- consoleWrite("Test MediaKeySession.");
- run('mediaKeySession = mediaKeys.createSession("video/webm", initData)');
- testExpected('typeof mediaKeySession', 'object');
- testExpected('typeof mediaKeySession.addEventListener', 'function');
- testExpected('typeof mediaKeySession.update', 'function');
- testExpected('mediaKeySession.error', null);
- testExpected('mediaKeySession.keySystem', 'org.w3.clearkey');
- testExpected('mediaKeySession.sessionId', null, '!=');
- testExpected('mediaKeySession.onwebkitkeyadded', null);
- testExpected('mediaKeySession.onwebkitkeyerror', null);
- testExpected('mediaKeySession.onwebkitkeymessage', null);
- testException('mediaKeySession.update()', '"TypeError: Failed to execute \'update\' on \'MediaKeySession\': 1 argument required, but only 0 present."');
- testDOMException('mediaKeySession.update(null)', "DOMException.INVALID_ACCESS_ERR");
- run('mediaKeySession.update(new Uint8Array(1))');
+ test_syntax(mediaKeySession.update.bind(mediaKeySession), [
+ [""],
+ [null],
+ [undefined],
+ [new Uint8Array(0)],
+ ], 'InvalidAccessError', 'Test MediaKeySession update() invalid access errors');
- run('mediaKeySession.release()');
+ test(function()
+ {
+ mediaKeySession.update(new Uint8Array(1));
+ mediaKeySession.update(new Uint8Array(1), extraParam);
+ }, "Test MediaKeySession update().");
- endTest();
- }
+ test(function()
+ {
+ mediaKeySession.release();
+ // Extra parameters are ignored.
+ // TODO(xhwang): This causes Chromium to crash. Uncomment this once Chromium is fixed.
ddorwin 2014/03/07 01:45:51 Yay for tests! :) Change to: FIXME: ^ no nam
xhwang 2014/03/08 00:37:45 Done.
+ // mediaKeySession.release(extraParam);
+ }, "Test MediaKeySession release().");
</script>
- </head>
- <body onload="runTest()">
- <p>This tests the basic API of MediaKeys and MediaKeySession.</p>
</body>
-</html>
+</html>
« no previous file with comments | « no previous file | LayoutTests/media/encrypted-media/encrypted-media-v2-syntax-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698