Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
2011-04-08 Leandro Gracia Gil <leandrogracia@chromium.org>
Reviewed by Steve Block. Media Stream API: add the getUserMedia method and the Javascript bindings. https://bugs.webkit.org/show_bug.cgi?id=56586 Test the Javascript behaviour of the getUserMedia method with different types of arguments. Current specification: http://www.whatwg.org/specs/web-apps/current-work/multipage/dnd.html#video-conferencing-and-peer-to-peer-communication * fast/dom/MediaStream/argument-types-expected.txt: Added. * fast/dom/MediaStream/argument-types.html: Added. * fast/dom/MediaStream/enabled-expected.txt: Added. * fast/dom/MediaStream/enabled.html: Added. * fast/dom/MediaStream/no-interface-object-expected.txt: Added. * fast/dom/MediaStream/no-interface-object.html: Added. * fast/dom/MediaStream/script-tests/argument-types.js: Added. (shouldNotThrow): (test): (emptyFunction): (): (ObjectThrowingException.prototype.valueOf): (ObjectThrowingException.prototype.toString): * fast/dom/MediaStream/script-tests/enabled.js: Added. (hasGetUserMediaProperty): * fast/dom/MediaStream/script-tests/no-interface-object.js: Added. (test): 2011-04-08 Leandro Gracia Gil <leandrogracia@chromium.org> Reviewed by Steve Block. Media Stream API: add the getUserMedia method and the Javascript bindings. https://bugs.webkit.org/show_bug.cgi?id=56586 Add the getUserMedia method to the navigator and its new Javascript types. Current specification: http://www.whatwg.org/specs/web-apps/current-work/multipage/dnd.html#video-conferencing-and-peer-to-peer-communication Tests: fast/dom/MediaStream/argument-types.html fast/dom/MediaStream/enabled.html fast/dom/MediaStream/no-interface-object.html * Android.derived.jscbindings.mk: * Android.derived.v8bindings.mk: * Android.v8bindings.mk: * CMakeLists.txt: * CodeGenerators.pri: * DerivedSources.cpp: * DerivedSources.make: * GNUmakefile.list.am: * WebCore.gypi: * WebCore.pro: * WebCore.vcproj/WebCore.vcproj: * WebCore.xcodeproj/project.pbxproj: * bindings/js/JSNavigatorCustom.cpp: (WebCore::JSNavigator::webkitGetUserMedia): * bindings/v8/custom/V8NavigatorCustom.cpp: Added. (WebCore::V8Navigator::webkitGetUserMediaCallback): * page/Navigator.cpp: (WebCore::Navigator::webkitGetUserMedia): * page/Navigator.h: * page/Navigator.idl: * page/NavigatorUserMediaError.h: Added. (WebCore::NavigatorUserMediaError::NavigatorUserMediaError): (WebCore::NavigatorUserMediaError::~NavigatorUserMediaError): (WebCore::NavigatorUserMediaError::code): * page/NavigatorUserMediaError.idl: Added. * page/NavigatorUserMediaErrorCallback.h: Added. (WebCore::NavigatorUserMediaErrorCallback::~NavigatorUserMediaErrorCallback): * page/NavigatorUserMediaErrorCallback.idl: Added. * page/NavigatorUserMediaSuccessCallback.h: Added. (WebCore::NavigatorUserMediaSuccessCallback::~NavigatorUserMediaSuccessCallback): * page/NavigatorUserMediaSuccessCallback.idl: Added. Canonical link: https://commits.webkit.org/73065@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@83287 268f45cc-cd09-0410-ab3c-d52691b4dbfc
- Loading branch information
Showing
34 changed files
with
954 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,49 @@ | ||
Tests the acceptable types for arguments to navigator.getUserMedia methods. | ||
|
||
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". | ||
|
||
|
||
PASS navigator.webkitGetUserMedia() threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17. | ||
PASS navigator.webkitGetUserMedia(undefined) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17. | ||
PASS navigator.webkitGetUserMedia(null) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17. | ||
PASS navigator.webkitGetUserMedia({}) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17. | ||
PASS navigator.webkitGetUserMedia(objectThrowingException) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17. | ||
PASS navigator.webkitGetUserMedia("video") threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17. | ||
PASS navigator.webkitGetUserMedia(true) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17. | ||
PASS navigator.webkitGetUserMedia(42) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17. | ||
PASS navigator.webkitGetUserMedia(Infinity) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17. | ||
PASS navigator.webkitGetUserMedia(-Infinity) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17. | ||
PASS navigator.webkitGetUserMedia(emptyFunction) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17. | ||
PASS navigator.webkitGetUserMedia("video", emptyFunction) did not throw exception. | ||
PASS navigator.webkitGetUserMedia(undefined, emptyFunction) did not throw exception. | ||
PASS navigator.webkitGetUserMedia(null, emptyFunction) did not throw exception. | ||
PASS navigator.webkitGetUserMedia({}, emptyFunction) did not throw exception. | ||
PASS navigator.webkitGetUserMedia(objectThrowingException, emptyFunction) threw exception Error: toString threw exception. | ||
PASS navigator.webkitGetUserMedia(true, emptyFunction) did not throw exception. | ||
PASS navigator.webkitGetUserMedia(42, emptyFunction) did not throw exception. | ||
PASS navigator.webkitGetUserMedia(Infinity, emptyFunction) did not throw exception. | ||
PASS navigator.webkitGetUserMedia(-Infinity, emptyFunction) did not throw exception. | ||
PASS navigator.webkitGetUserMedia(emptyFunction, emptyFunction) did not throw exception. | ||
PASS navigator.webkitGetUserMedia("video", "video") threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17. | ||
PASS navigator.webkitGetUserMedia("video", undefined) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17. | ||
PASS navigator.webkitGetUserMedia("video", null) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17. | ||
PASS navigator.webkitGetUserMedia("video", {}) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17. | ||
PASS navigator.webkitGetUserMedia("video", objectThrowingException) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17. | ||
PASS navigator.webkitGetUserMedia("video", true) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17. | ||
PASS navigator.webkitGetUserMedia("video", 42) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17. | ||
PASS navigator.webkitGetUserMedia("video", Infinity) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17. | ||
PASS navigator.webkitGetUserMedia("video", -Infinity) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17. | ||
PASS navigator.webkitGetUserMedia("video", emptyFunction, emptyFunction) did not throw exception. | ||
PASS navigator.webkitGetUserMedia("video", emptyFunction, undefined) did not throw exception. | ||
PASS navigator.webkitGetUserMedia("video", emptyFunction, "video") threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17. | ||
PASS navigator.webkitGetUserMedia("video", emptyFunction, null) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17. | ||
PASS navigator.webkitGetUserMedia("video", emptyFunction, {}) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17. | ||
PASS navigator.webkitGetUserMedia("video", emptyFunction, objectThrowingException) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17. | ||
PASS navigator.webkitGetUserMedia("video", emptyFunction, true) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17. | ||
PASS navigator.webkitGetUserMedia("video", emptyFunction, 42) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17. | ||
PASS navigator.webkitGetUserMedia("video", emptyFunction, Infinity) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17. | ||
PASS navigator.webkitGetUserMedia("video", emptyFunction, -Infinity) threw exception Error: TYPE_MISMATCH_ERR: DOM Exception 17. | ||
PASS successfullyParsed is true | ||
|
||
TEST COMPLETE | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,13 @@ | ||
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> | ||
<html> | ||
<head> | ||
<link rel="stylesheet" href="../../js/resources/js-test-style.css"> | ||
<script src="../../js/resources/js-test-pre.js"></script> | ||
</head> | ||
<body> | ||
<p id="description"></p> | ||
<div id="console"></div> | ||
<script src="script-tests/argument-types.js"></script> | ||
<script src="../../js/resources/js-test-post.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,13 @@ | ||
Tests that navigator.webkitGetUserMedia is present. | ||
|
||
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". | ||
|
||
|
||
PASS typeof navigator.webkitGetUserMedia == 'function' is true | ||
PASS hasGetUserMediaProperty() is true | ||
PASS 'webkitGetUserMedia' in navigator is true | ||
PASS navigator.hasOwnProperty('webkitGetUserMedia') is false | ||
PASS successfullyParsed is true | ||
|
||
TEST COMPLETE | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,13 @@ | ||
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> | ||
<html> | ||
<head> | ||
<link rel="stylesheet" href="../../js/resources/js-test-style.css"> | ||
<script src="../../js/resources/js-test-pre.js"></script> | ||
</head> | ||
<body> | ||
<p id="description"></p> | ||
<div id="console"></div> | ||
<script src="script-tests/enabled.js"></script> | ||
<script src="../../js/resources/js-test-post.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,17 @@ | ||
Tests that the following classes are not manipulable by JavaScript (NoInterfaceObject). | ||
|
||
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". | ||
|
||
|
||
PASS typeof NavigatorUserMedia is "undefined" | ||
PASS NavigatorUserMedia.prototype threw exception ReferenceError: NavigatorUserMedia is not defined. | ||
PASS typeof NavigatorUserMediaError is "undefined" | ||
PASS NavigatorUserMediaError.prototype threw exception ReferenceError: NavigatorUserMediaError is not defined. | ||
PASS typeof NavigatorUserMediaSuccessCallback is "undefined" | ||
PASS NavigatorUserMediaSuccessCallback.prototype threw exception ReferenceError: NavigatorUserMediaSuccessCallback is not defined. | ||
PASS typeof NavigatorUserMediaErrorCallback is "undefined" | ||
PASS NavigatorUserMediaErrorCallback.prototype threw exception ReferenceError: NavigatorUserMediaErrorCallback is not defined. | ||
PASS successfullyParsed is true | ||
|
||
TEST COMPLETE | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,13 @@ | ||
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> | ||
<html> | ||
<head> | ||
<link rel="stylesheet" href="../../js/resources/js-test-style.css"> | ||
<script src="../../js/resources/js-test-pre.js"></script> | ||
</head> | ||
<body> | ||
<p id="description"></p> | ||
<div id="console"></div> | ||
<script src="script-tests/no-interface-object.js"></script> | ||
<script src="../../js/resources/js-test-post.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,85 @@ | ||
description("Tests the acceptable types for arguments to navigator.getUserMedia methods."); | ||
|
||
function shouldNotThrow(expression) | ||
{ | ||
try { | ||
eval(expression); | ||
testPassed(expression + " did not throw exception."); | ||
} catch(e) { | ||
testFailed(expression + " should not throw exception. Threw exception " + e); | ||
} | ||
} | ||
|
||
function test(expression, expressionShouldThrow, expectedException) { | ||
if (expressionShouldThrow) { | ||
if (expectedException) | ||
shouldThrow(expression, '(function() { return "' + expectedException + '"; })();'); | ||
else | ||
shouldThrow(expression, '(function() { return "Error: TYPE_MISMATCH_ERR: DOM Exception 17"; })();'); | ||
} else { | ||
shouldNotThrow(expression); | ||
} | ||
} | ||
|
||
var emptyFunction = function() {}; | ||
|
||
function ObjectThrowingException() {}; | ||
ObjectThrowingException.prototype.valueOf = function() { | ||
throw new Error('valueOf threw exception'); | ||
} | ||
ObjectThrowingException.prototype.toString = function() { | ||
throw new Error('toString threw exception'); | ||
} | ||
var objectThrowingException = new ObjectThrowingException(); | ||
|
||
// No arguments | ||
test('navigator.webkitGetUserMedia()', true); | ||
|
||
// 1 Argument (getUserMedia requires at least 2 arguments). | ||
test('navigator.webkitGetUserMedia(undefined)', true); | ||
test('navigator.webkitGetUserMedia(null)', true); | ||
test('navigator.webkitGetUserMedia({})', true); | ||
test('navigator.webkitGetUserMedia(objectThrowingException)', true); | ||
test('navigator.webkitGetUserMedia("video")', true); | ||
test('navigator.webkitGetUserMedia(true)', true); | ||
test('navigator.webkitGetUserMedia(42)', true); | ||
test('navigator.webkitGetUserMedia(Infinity)', true); | ||
test('navigator.webkitGetUserMedia(-Infinity)', true); | ||
test('navigator.webkitGetUserMedia(emptyFunction)', true); | ||
|
||
// 2 Arguments. | ||
test('navigator.webkitGetUserMedia("video", emptyFunction)', false); | ||
test('navigator.webkitGetUserMedia(undefined, emptyFunction)', false); | ||
test('navigator.webkitGetUserMedia(null, emptyFunction)', false); | ||
test('navigator.webkitGetUserMedia({}, emptyFunction)', false); | ||
test('navigator.webkitGetUserMedia(objectThrowingException, emptyFunction)', true, new Error('toString threw exception')); | ||
test('navigator.webkitGetUserMedia(true, emptyFunction)', false); | ||
test('navigator.webkitGetUserMedia(42, emptyFunction)', false); | ||
test('navigator.webkitGetUserMedia(Infinity, emptyFunction)', false); | ||
test('navigator.webkitGetUserMedia(-Infinity, emptyFunction)', false); | ||
test('navigator.webkitGetUserMedia(emptyFunction, emptyFunction)', false); | ||
|
||
test('navigator.webkitGetUserMedia("video", "video")', true); | ||
test('navigator.webkitGetUserMedia("video", undefined)', true); | ||
test('navigator.webkitGetUserMedia("video", null)', true); | ||
test('navigator.webkitGetUserMedia("video", {})', true); | ||
test('navigator.webkitGetUserMedia("video", objectThrowingException)', true); | ||
test('navigator.webkitGetUserMedia("video", true)', true); | ||
test('navigator.webkitGetUserMedia("video", 42)', true); | ||
test('navigator.webkitGetUserMedia("video", Infinity)', true); | ||
test('navigator.webkitGetUserMedia("video", -Infinity)', true); | ||
|
||
// 3 Arguments. | ||
test('navigator.webkitGetUserMedia("video", emptyFunction, emptyFunction)', false); | ||
test('navigator.webkitGetUserMedia("video", emptyFunction, undefined)', false); | ||
test('navigator.webkitGetUserMedia("video", emptyFunction, "video")', true); | ||
test('navigator.webkitGetUserMedia("video", emptyFunction, null)', true); | ||
test('navigator.webkitGetUserMedia("video", emptyFunction, {})', true); | ||
test('navigator.webkitGetUserMedia("video", emptyFunction, objectThrowingException)', true); | ||
test('navigator.webkitGetUserMedia("video", emptyFunction, true)', true); | ||
test('navigator.webkitGetUserMedia("video", emptyFunction, 42)', true); | ||
test('navigator.webkitGetUserMedia("video", emptyFunction, Infinity)', true); | ||
test('navigator.webkitGetUserMedia("video", emptyFunction, -Infinity)', true); | ||
|
||
window.jsTestIsAsync = false; | ||
window.successfullyParsed = true; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,18 @@ | ||
description("Tests that navigator.webkitGetUserMedia is present."); | ||
|
||
function hasGetUserMediaProperty() | ||
{ | ||
for (var property in navigator) { | ||
if (property == "webkitGetUserMedia") | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
shouldBeTrue("typeof navigator.webkitGetUserMedia == 'function'"); | ||
shouldBeTrue("hasGetUserMediaProperty()"); | ||
shouldBeTrue("'webkitGetUserMedia' in navigator"); | ||
shouldBeFalse("navigator.hasOwnProperty('webkitGetUserMedia')"); | ||
|
||
window.jsTestIsAsync = false; | ||
window.successfullyParsed = true; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -0,0 +1,15 @@ | ||
description("Tests that the following classes are not manipulable by JavaScript (NoInterfaceObject)."); | ||
|
||
function test(name) | ||
{ | ||
shouldBe('typeof ' + name, '"undefined"'); | ||
shouldThrow(name + '.prototype'); | ||
} | ||
|
||
test('NavigatorUserMedia'); | ||
test('NavigatorUserMediaError'); | ||
test('NavigatorUserMediaSuccessCallback'); | ||
test('NavigatorUserMediaErrorCallback'); | ||
|
||
window.jsTestIsAsync = false; | ||
window.successfullyParsed = true; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.