Commit 4765095d authored by commit-queue@webkit.org's avatar commit-queue@webkit.org
Browse files

Tests for exceptions of type DOMException.TYPE_ERR in encrypted-media-syntax.html are broken

https://bugs.webkit.org/show_bug.cgi?id=113119

Renames testException() to testDOMException() and tweaks the check.
Also adds a new testException() helper for checking non-DOM exceptions.

Patch by Steve Block <steveblock@chromium.org> on 2013-04-08
Reviewed by Darin Adler.

* media/encrypted-media/encrypted-media-not-loaded.html:
* media/encrypted-media/encrypted-media-syntax-expected.txt:
* media/encrypted-media/encrypted-media-syntax.html:
* media/encrypted-media/encrypted-media-v2-syntax.html:
* media/media-fullscreen.js:
(buttonClickHandler):
(canplaythrough):
* media/track/track-add-remove-cue.html:
* media/track/track-addtrack-kind.html:
* media/track/track-cue-mutable.html:
* media/video-buffered.html:
* media/video-play-require-user-gesture.html:
* media/video-seek-no-src-exception.html:
* media/video-seekable.html:
* media/video-test.js:
(testDOMException):
* media/video-volume.html:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@147969 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent cf28c9c6
2013-04-08 Steve Block <steveblock@chromium.org>
Tests for exceptions of type DOMException.TYPE_ERR in encrypted-media-syntax.html are broken
https://bugs.webkit.org/show_bug.cgi?id=113119
Renames testException() to testDOMException() and tweaks the check.
Also adds a new testException() helper for checking non-DOM exceptions.
Reviewed by Darin Adler.
* media/encrypted-media/encrypted-media-not-loaded.html:
* media/encrypted-media/encrypted-media-syntax-expected.txt:
* media/encrypted-media/encrypted-media-syntax.html:
* media/encrypted-media/encrypted-media-v2-syntax.html:
* media/media-fullscreen.js:
(buttonClickHandler):
(canplaythrough):
* media/track/track-add-remove-cue.html:
* media/track/track-addtrack-kind.html:
* media/track/track-cue-mutable.html:
* media/video-buffered.html:
* media/video-play-require-user-gesture.html:
* media/video-seek-no-src-exception.html:
* media/video-seekable.html:
* media/video-test.js:
(testDOMException):
* media/video-volume.html:
2013-04-08 Brady Eidson <beidson@apple.com>
 
Skip async plugin test while fixing the failure.
......@@ -29,9 +29,9 @@
testExpected("video.currentSrc", "");
consoleWrite("No 'src'. Verify that all methods except canPlayType() throw INVALID_STATE_ERR.");
testException("video.webkitGenerateKeyRequest('webkit-org.w3.clearkey')", "DOMException.INVALID_STATE_ERR");
testException("video.webkitAddKey('webkit-org.w3.clearkey', key)", "DOMException.INVALID_STATE_ERR");
testException("video.webkitCancelKeyRequest('webkit-org.w3.clearkey')", "DOMException.INVALID_STATE_ERR");
testDOMException("video.webkitGenerateKeyRequest('webkit-org.w3.clearkey')", "DOMException.INVALID_STATE_ERR");
testDOMException("video.webkitAddKey('webkit-org.w3.clearkey', key)", "DOMException.INVALID_STATE_ERR");
testDOMException("video.webkitCancelKeyRequest('webkit-org.w3.clearkey')", "DOMException.INVALID_STATE_ERR");
run("video.canPlayType('audio/wav', 'webkit-org.w3.clearkey')");
video.setAttribute("src", findMediaFile("video", "../content/test"));
......@@ -41,9 +41,9 @@
testExpected("video.networkState", video.NETWORK_NO_SOURCE);
testExpected("video.currentSrc", "");
testException("video.webkitGenerateKeyRequest('webkit-org.w3.clearkey')", "DOMException.INVALID_STATE_ERR");
testException("video.webkitAddKey('webkit-org.w3.clearkey', key)", "DOMException.INVALID_STATE_ERR");
testException("video.webkitCancelKeyRequest('webkit-org.w3.clearkey')", "DOMException.INVALID_STATE_ERR");
testDOMException("video.webkitGenerateKeyRequest('webkit-org.w3.clearkey')", "DOMException.INVALID_STATE_ERR");
testDOMException("video.webkitAddKey('webkit-org.w3.clearkey', key)", "DOMException.INVALID_STATE_ERR");
testDOMException("video.webkitCancelKeyRequest('webkit-org.w3.clearkey')", "DOMException.INVALID_STATE_ERR");
run("video.canPlayType('audio/wav', 'webkit-org.w3.clearkey')");
......
Tests invalid and valid syntaxes.
Test calling functions with too few parameters.
TEST(video.webkitGenerateKeyRequest()) THROWS(DOMException.TYPE_ERR) OK
TEST(video.webkitAddKey()) THROWS(DOMException.TYPE_ERR) OK
TEST(video.webkitAddKey('webkit-org.w3.clearkey')) THROWS(DOMException.TYPE_ERR) OK
TEST(video.webkitCancelKeyRequest()) THROWS(DOMException.TYPE_ERR) OK
TEST(video.webkitGenerateKeyRequest()) THROWS("TypeError: Not enough arguments") OK
TEST(video.webkitAddKey()) THROWS("TypeError: Not enough arguments") OK
TEST(video.webkitAddKey('webkit-org.w3.clearkey')) THROWS("TypeError: Not enough arguments") OK
TEST(video.webkitCancelKeyRequest()) THROWS("TypeError: Not enough arguments") OK
Verify invalid key system parameter is caught before checking whether loading has started.
EXPECTED (video.networkState == '0') OK
......
......@@ -27,46 +27,47 @@
run("video.webkitCancelKeyRequest('webkit-org.w3.clearkey', 'session')");
consoleWrite("<br>Unsupported key systems result in NOT_SUPPORTED_ERR.");
testException("video.webkitGenerateKeyRequest('com.example.invalid')", "DOMException.NOT_SUPPORTED_ERR");
testException("video.webkitAddKey('com.example.invalid', key)", "DOMException.NOT_SUPPORTED_ERR");
testException("video.webkitCancelKeyRequest('com.example.invalid')", "DOMException.NOT_SUPPORTED_ERR");
testDOMException("video.webkitGenerateKeyRequest('com.example.invalid')", "DOMException.NOT_SUPPORTED_ERR");
testDOMException("video.webkitAddKey('com.example.invalid', key)", "DOMException.NOT_SUPPORTED_ERR");
testDOMException("video.webkitCancelKeyRequest('com.example.invalid')", "DOMException.NOT_SUPPORTED_ERR");
endTest();
}
consoleWrite("Test calling functions with too few parameters.");
testException("video.webkitGenerateKeyRequest()", "DOMException.TYPE_ERR");
testException("video.webkitAddKey()", "DOMException.TYPE_ERR");
testException("video.webkitAddKey('webkit-org.w3.clearkey')", "DOMException.TYPE_ERR");
testException("video.webkitCancelKeyRequest()", "DOMException.TYPE_ERR");
var notEnoughArgumentsException = '"TypeError: Not enough arguments"';
testException("video.webkitGenerateKeyRequest()", notEnoughArgumentsException);
testException("video.webkitAddKey()", notEnoughArgumentsException);
testException("video.webkitAddKey('webkit-org.w3.clearkey')", notEnoughArgumentsException);
testException("video.webkitCancelKeyRequest()", notEnoughArgumentsException);
consoleWrite("<br>Verify invalid key system parameter is caught before checking whether loading has started.");
// If the above was not the case, all of these would be INVALID_STATE_ERR.
// Also tests "null" case for first parameter.
testExpected("video.networkState", video.NETWORK_EMPTY);
testExpected("video.currentSrc", "");
testException("video.webkitGenerateKeyRequest('')", "DOMException.SYNTAX_ERR");
testException("video.webkitGenerateKeyRequest(null)", "DOMException.SYNTAX_ERR");
testException("video.webkitGenerateKeyRequest(undefined)", "DOMException.SYNTAX_ERR");
testException("video.webkitAddKey('', key)", "DOMException.SYNTAX_ERR");
testException("video.webkitAddKey(null, key)", "DOMException.SYNTAX_ERR");
testException("video.webkitAddKey(undefined, key)", "DOMException.SYNTAX_ERR");
testException("video.webkitCancelKeyRequest('')", "DOMException.SYNTAX_ERR");
testException("video.webkitCancelKeyRequest(null)", "DOMException.SYNTAX_ERR");
testException("video.webkitCancelKeyRequest(undefined)", "DOMException.SYNTAX_ERR");
testDOMException("video.webkitGenerateKeyRequest('')", "DOMException.SYNTAX_ERR");
testDOMException("video.webkitGenerateKeyRequest(null)", "DOMException.SYNTAX_ERR");
testDOMException("video.webkitGenerateKeyRequest(undefined)", "DOMException.SYNTAX_ERR");
testDOMException("video.webkitAddKey('', key)", "DOMException.SYNTAX_ERR");
testDOMException("video.webkitAddKey(null, key)", "DOMException.SYNTAX_ERR");
testDOMException("video.webkitAddKey(undefined, key)", "DOMException.SYNTAX_ERR");
testDOMException("video.webkitCancelKeyRequest('')", "DOMException.SYNTAX_ERR");
testDOMException("video.webkitCancelKeyRequest(null)", "DOMException.SYNTAX_ERR");
testDOMException("video.webkitCancelKeyRequest(undefined)", "DOMException.SYNTAX_ERR");
consoleWrite("<br>null key is caught before load state is checked.");
testException("video.webkitAddKey('webkit-org.w3.clearkey', '')", "DOMException.SYNTAX_ERR");
testException("video.webkitAddKey('webkit-org.w3.clearkey', null)", "DOMException.SYNTAX_ERR");
testException("video.webkitAddKey('webkit-org.w3.clearkey', undefined)", "DOMException.SYNTAX_ERR");
testDOMException("video.webkitAddKey('webkit-org.w3.clearkey', '')", "DOMException.SYNTAX_ERR");
testDOMException("video.webkitAddKey('webkit-org.w3.clearkey', null)", "DOMException.SYNTAX_ERR");
testDOMException("video.webkitAddKey('webkit-org.w3.clearkey', undefined)", "DOMException.SYNTAX_ERR");
consoleWrite("<br>0-length key is caught before load state is checked.");
testException("video.webkitAddKey('webkit-org.w3.clearkey', new Uint8Array())", "DOMException.TYPE_MISMATCH_ERR");
testDOMException("video.webkitAddKey('webkit-org.w3.clearkey', new Uint8Array())", "DOMException.TYPE_MISMATCH_ERR");
consoleWrite("<br>Key system validity is not checked before loading.");
testException("video.webkitGenerateKeyRequest('com.example.invalid')", "DOMException.INVALID_STATE_ERR");
testException("video.webkitAddKey('com.example.invalid', key)", "DOMException.INVALID_STATE_ERR");
testException("video.webkitCancelKeyRequest('com.example.invalid')", "DOMException.INVALID_STATE_ERR");
testDOMException("video.webkitGenerateKeyRequest('com.example.invalid')", "DOMException.INVALID_STATE_ERR");
testDOMException("video.webkitAddKey('com.example.invalid', key)", "DOMException.INVALID_STATE_ERR");
testDOMException("video.webkitCancelKeyRequest('com.example.invalid')", "DOMException.INVALID_STATE_ERR");
// FIXME(82952): Add "test-encrypted" file.
video.setAttribute("src", findMediaFile("video", "../content/test"));
......
......@@ -26,13 +26,13 @@
consoleWrite("Test MediaKeys.");
testExpected('typeof window.MediaKeys', 'object');
testException('new MediaKeys("")', "DOMException.INVALID_ACCESS_ERR");
testException('new MediaKeys("unsupported")', "DOMException.NOT_SUPPORTED_ERR");
testDOMException('new MediaKeys("")', "DOMException.INVALID_ACCESS_ERR");
testDOMException('new MediaKeys("unsupported")', "DOMException.NOT_SUPPORTED_ERR");
run('mediaKeys = new MediaKeys("com.webcore.mock")');
testExpected('mediaKeys.keySystem', 'com.webcore.mock');
testExpected('typeof mediaKeys.createSession', 'function');
testException('mediaKeys.createSession("", new Uint8Array(1))', "DOMException.INVALID_ACCESS_ERR");
testException('mediaKeys.createSession("unsupported/type")', "DOMException.NOT_SUPPORTED_ERR");
testDOMException('mediaKeys.createSession("", new Uint8Array(1))', "DOMException.INVALID_ACCESS_ERR");
testDOMException('mediaKeys.createSession("unsupported/type")', "DOMException.NOT_SUPPORTED_ERR");
consoleWrite("");
consoleWrite("Test MediaKeySession.");
......@@ -46,7 +46,7 @@
testExpected('mediaKeySession.onwebkitkeyadded', null);
testExpected('mediaKeySession.onwebkitkeyerror', null);
testExpected('mediaKeySession.onwebkitkeymessage', null);
testException('mediaKeySession.update(null)', "DOMException.INVALID_ACCESS_ERR");
testDOMException('mediaKeySession.update(null)', "DOMException.INVALID_ACCESS_ERR");
endTest();
}
</script>
......
......@@ -13,7 +13,7 @@ function buttonClickHandler()
run("mediaElement.webkitEnterFullScreen()");
else {
if (movie.type == 'video')
testException("mediaElement.webkitEnterFullScreen()", "DOMException.INVALID_STATE_ERR");
testDOMException("mediaElement.webkitEnterFullScreen()", "DOMException.INVALID_STATE_ERR");
openNextMovie();
}
}
......@@ -63,7 +63,7 @@ function canplaythrough()
// Verify that we get an exception when trying to enter fullscreen since this isn't
// called in response to a user gesture.
if (movie.type == 'video')
testException("mediaElement.webkitEnterFullScreen()", "DOMException.INVALID_STATE_ERR");
testDOMException("mediaElement.webkitEnterFullScreen()", "DOMException.INVALID_STATE_ERR");
// Click on the button
if (window.testRunner)
......
......@@ -85,7 +85,7 @@
testExpected("cues[2].startTime", 121);
consoleWrite("<br>*** Try to remove the cue again.");
testException("testTrack.track.removeCue(textCue)", "DOMException.NOT_FOUND_ERR");
testDOMException("testTrack.track.removeCue(textCue)", "DOMException.NOT_FOUND_ERR");
consoleWrite("<br>*** Add a cue before all the existing cues.");
run("testTrack.track.addCue(new TextTrackCue(0, 31, 'I am first'))");
......
......@@ -21,7 +21,7 @@
consoleWrite("<em>++ Test invalid 'kind'.</em>");
testExpected("video.textTracks.length", 0);
testException("video.addTextTrack('kaptions')", "DOMException.SYNTAX_ERR");
testDOMException("video.addTextTrack('kaptions')", "DOMException.SYNTAX_ERR");
testExpected("video.textTracks.length", 0);
consoleWrite("");
......
......@@ -48,7 +48,7 @@
logSpecURL("http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#dom-texttrackcue-vertical",
"On setting, the text track cue writing direction must be set to the value ... is a case-sensitive match for the new value, if any. If none of the values match, then the user agent must instead throw a SyntaxError exception.");
testException("textCue.vertical = 'RL'", "DOMException.SYNTAX_ERR");
testDOMException("textCue.vertical = 'RL'", "DOMException.SYNTAX_ERR");
testExpected("textCue.vertical", "");
run("textCue.vertical = 'rl'");
testExpected("textCue.vertical", "rl");
......@@ -59,8 +59,8 @@
logSpecURL("http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#dom-texttrackcue-line",
"On setting, if the text track cue snap-to-lines flag is not set, and the new value is negative or greater than 100, then throw an IndexSizeError exception.");
testException("textCue.line = -2", "DOMException.INDEX_SIZE_ERR");
testException("textCue.line = 102", "DOMException.INDEX_SIZE_ERR");
testDOMException("textCue.line = -2", "DOMException.INDEX_SIZE_ERR");
testDOMException("textCue.line = 102", "DOMException.INDEX_SIZE_ERR");
testExpected("textCue.line", -1);
run("textCue.line = 42");
testExpected("textCue.line", 42);
......@@ -72,21 +72,21 @@
logSpecURL("http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#dom-texttrackcue-line",
"On setting, if the new value is negative or greater than 100, then throw an IndexSizeError exception. Otherwise, set the text track cue text position to the new value.");
testException("textCue.position = -200", "DOMException.INDEX_SIZE_ERR");
testException("textCue.position = 110", "DOMException.INDEX_SIZE_ERR");
testDOMException("textCue.position = -200", "DOMException.INDEX_SIZE_ERR");
testDOMException("textCue.position = 110", "DOMException.INDEX_SIZE_ERR");
run("textCue.position = 11");
testExpected("textCue.position", 11);
logSpecURL("http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#dom-texttrackcue-size",
"On setting, if the new value is negative or greater than 100, then throw an IndexSizeError exception. Otherwise, set the text track cue size to the new value.");
testException("textCue.size = -200", "DOMException.INDEX_SIZE_ERR");
testException("textCue.size = 110", "DOMException.INDEX_SIZE_ERR");
testDOMException("textCue.size = -200", "DOMException.INDEX_SIZE_ERR");
testDOMException("textCue.size = 110", "DOMException.INDEX_SIZE_ERR");
run("textCue.size = 57");
testExpected("textCue.size", 57);
logSpecURL("http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#dom-texttrackcue-align",
"On setting, the text track cue alignment must be set to the value ... is a case-sensitive match for the new value, if any. If none of the values match, then the user agent must instead throw a SyntaxError exception.");
testException("textCue.align = 'End'", "DOMException.SYNTAX_ERR");
testDOMException("textCue.align = 'End'", "DOMException.SYNTAX_ERR");
testExpected("textCue.align", "middle");
run("textCue.align = 'end'");
testExpected("textCue.align", "end");
......
......@@ -3,20 +3,20 @@
<script src=video-test.js></script>
<script>
testExpected("video.buffered.length", 0);
testException("video.buffered.start(-1)", "DOMException.INDEX_SIZE_ERR");
testException("video.buffered.end(-1)", "DOMException.INDEX_SIZE_ERR");
testException("video.buffered.start(0)", "DOMException.INDEX_SIZE_ERR");
testException("video.buffered.end(0)", "DOMException.INDEX_SIZE_ERR");
testDOMException("video.buffered.start(-1)", "DOMException.INDEX_SIZE_ERR");
testDOMException("video.buffered.end(-1)", "DOMException.INDEX_SIZE_ERR");
testDOMException("video.buffered.start(0)", "DOMException.INDEX_SIZE_ERR");
testDOMException("video.buffered.end(0)", "DOMException.INDEX_SIZE_ERR");
waitForEvent('canplaythrough',
function ()
{
testExpected("video.buffered.length", 1);
testExpected("video.buffered.start(0)", 0);
testExpected("video.buffered.end(0)", 0, '>');
testException("video.buffered.start(-1)", "DOMException.INDEX_SIZE_ERR");
testException("video.buffered.end(-1)", "DOMException.INDEX_SIZE_ERR");
testException("video.buffered.start(1)", "DOMException.INDEX_SIZE_ERR");
testException("video.buffered.end(1)", "DOMException.INDEX_SIZE_ERR");
testDOMException("video.buffered.start(-1)", "DOMException.INDEX_SIZE_ERR");
testDOMException("video.buffered.end(-1)", "DOMException.INDEX_SIZE_ERR");
testDOMException("video.buffered.start(1)", "DOMException.INDEX_SIZE_ERR");
testDOMException("video.buffered.end(1)", "DOMException.INDEX_SIZE_ERR");
endTest();
}
);
......
......@@ -57,7 +57,7 @@
consoleWrite("");
consoleWrite("* No user gesture initiated");
run("video.play()");
testException("video.webkitEnterFullScreen()", "DOMException.INVALID_STATE_ERR");
testDOMException("video.webkitEnterFullScreen()", "DOMException.INVALID_STATE_ERR");
testExpected("video.paused", true);
consoleWrite("");
......
......@@ -9,7 +9,7 @@
<script>
testExpected("video.networkState", HTMLMediaElement.NETWORK_EMPTY);
testExpected("video.readyState", HTMLMediaElement.HAVE_NOTHING);
testException("video.currentTime = 1.1", "DOMException.INVALID_STATE_ERR");
testDOMException("video.currentTime = 1.1", "DOMException.INVALID_STATE_ERR");
setTimeout(endTest, 200)
</script>
......
......@@ -3,20 +3,20 @@
<script src=video-test.js></script>
<script>
testExpected("video.seekable.length", 0);
testException("video.seekable.start(-1)", "DOMException.INDEX_SIZE_ERR");
testException("video.seekable.end(-1)", "DOMException.INDEX_SIZE_ERR");
testException("video.seekable.start(0)", "DOMException.INDEX_SIZE_ERR");
testException("video.seekable.end(0)", "DOMException.INDEX_SIZE_ERR");
testDOMException("video.seekable.start(-1)", "DOMException.INDEX_SIZE_ERR");
testDOMException("video.seekable.end(-1)", "DOMException.INDEX_SIZE_ERR");
testDOMException("video.seekable.start(0)", "DOMException.INDEX_SIZE_ERR");
testDOMException("video.seekable.end(0)", "DOMException.INDEX_SIZE_ERR");
waitForEvent('canplaythrough',
function ()
{
testExpected("video.seekable.length", 1);
testExpected("video.seekable.start(0)", 0);
testExpected("video.seekable.end(0)", 0, ">");
testException("video.seekable.start(-1)", "DOMException.INDEX_SIZE_ERR");
testException("video.seekable.end(-1)", "DOMException.INDEX_SIZE_ERR");
testException("video.seekable.start(1)", "DOMException.INDEX_SIZE_ERR");
testException("video.seekable.end(1)", "DOMException.INDEX_SIZE_ERR");
testDOMException("video.seekable.start(-1)", "DOMException.INDEX_SIZE_ERR");
testDOMException("video.seekable.end(-1)", "DOMException.INDEX_SIZE_ERR");
testDOMException("video.seekable.start(1)", "DOMException.INDEX_SIZE_ERR");
testDOMException("video.seekable.end(1)", "DOMException.INDEX_SIZE_ERR");
endTest();
}
);
......
......@@ -202,13 +202,25 @@ function waitForEventAndTest(eventName, testFuncString, endit)
mediaElement.addEventListener(eventName, _eventCallback, true);
}
function testException(testString, exceptionString)
function testDOMException(testString, exceptionString)
{
try {
eval(testString);
} catch (ex) {
logResult(ex.code == eval(exceptionString), "TEST(" + testString + ") THROWS("+exceptionString+")");
var exception = ex;
}
logResult(exception instanceof DOMException && exception.code === eval(exceptionString),
"TEST(" + testString + ") THROWS(" + exceptionString + ")");
}
function testException(testString, exceptionString) {
try {
eval(testString);
} catch (ex) {
var exception = ex;
}
logResult(exception !== undefined && exception == eval(exceptionString),
"TEST(" + testString + ") THROWS(" + exceptionString + ")");
}
var testEnded = false;
......
......@@ -8,16 +8,16 @@
testExpected("video.volume", 0.5);
run("video.volume = 0");
testExpected("video.volume", 0);
testException("video.volume = 1.5", "DOMException.INDEX_SIZE_ERR");
testException("video.volume = -0.5", "DOMException.INDEX_SIZE_ERR");
testDOMException("video.volume = 1.5", "DOMException.INDEX_SIZE_ERR");
testDOMException("video.volume = -0.5", "DOMException.INDEX_SIZE_ERR");
video.src = findMediaFile("video", "content/test");
run("video.load()");
waitForEvent("canplaythrough", function () {
testExpected("video.volume", 0);
run("video.volume = 0.5");
testExpected("video.volume", 0.5);
testException("video.volume = 1.5", "DOMException.INDEX_SIZE_ERR");
testException("video.volume = -0.5", "DOMException.INDEX_SIZE_ERR");
testDOMException("video.volume = 1.5", "DOMException.INDEX_SIZE_ERR");
testDOMException("video.volume = -0.5", "DOMException.INDEX_SIZE_ERR");
endTest();
});
</script>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment