Skip to content
Permalink
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
Steve Block committed Apr 8, 2011
1 parent af851d0 commit 122da8c29a4b4babd697d2a2ed766c360a0cde60
Showing 34 changed files with 954 additions and 1 deletion.
@@ -1,3 +1,31 @@
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 Mikhail Naganov <mnaganov@chromium.org>

Reviewed by Pavel Feldman.
@@ -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

@@ -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>
@@ -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

@@ -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>
@@ -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

@@ -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>
@@ -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;
@@ -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;
@@ -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;
@@ -296,6 +296,9 @@ GEN := \
$(intermediates)/page/JSHistory.h \
$(intermediates)/page/JSLocation.h \
$(intermediates)/page/JSNavigator.h \
$(intermediates)/page/JSNavigatorUserMediaError.h \
$(intermediates)/page/JSNavigatorUserMediaErrorCallback.h \
$(intermediates)/page/JSNavigatorUserMediaSuccessCallback.h \
$(intermediates)/page/JSPositionError.h \
$(intermediates)/page/JSScreen.h \
$(intermediates)/page/JSWebKitAnimation.h \
@@ -277,6 +277,9 @@ GEN := \
$(intermediates)/bindings/V8History.h \
$(intermediates)/bindings/V8Location.h \
$(intermediates)/bindings/V8Navigator.h \
$(intermediates)/bindings/V8NavigatorUserMediaError.h \
$(intermediates)/bindings/V8NavigatorUserMediaErrorCallback.h \
$(intermediates)/bindings/V8NavigatorUserMediaSuccessCallback.h \
$(intermediates)/bindings/V8PositionError.h \
$(intermediates)/bindings/V8Screen.h \
$(intermediates)/bindings/V8WebKitAnimation.h \
@@ -141,6 +141,7 @@ LOCAL_SRC_FILES += \
bindings/v8/custom/V8MessageChannelConstructor.cpp \
bindings/v8/custom/V8MessagePortCustom.cpp \
bindings/v8/custom/V8MessageEventCustom.cpp \
bindings/v8/custom/V8NavigatorCustom.cpp \
bindings/v8/custom/V8NamedNodeMapCustom.cpp \
bindings/v8/custom/V8NamedNodesCollection.cpp \
bindings/v8/custom/V8NodeCustom.cpp \
@@ -330,6 +330,8 @@ SET(WebCore_IDL_FILES
page/Location.idl
page/MemoryInfo.idl
page/Navigator.idl
page/NavigatorUserMediaErrorCallback.idl
page/NavigatorUserMediaSuccessCallback.idl
page/Performance.idl
page/PerformanceNavigation.idl
page/PerformanceTiming.idl
@@ -1946,6 +1948,16 @@ IF (ENABLE_PROGRESS_TAG)
)
ENDIF ()

IF (ENABLE_MEDIA_STREAM)
LIST(APPEND WebCore_SOURCES
bindings/js/JSNavigatorCustom.cpp
)

LIST(APPEND WebCore_IDL_FILES
page/NavigatorUserMediaError.idl
)
ENDIF ()



# Modules that the bindings generator scripts may use
@@ -1,3 +1,49 @@
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.

2011-04-08 Mikhail Naganov <mnaganov@chromium.org>

Reviewed by Pavel Feldman.
@@ -325,6 +325,9 @@ IDL_BINDINGS += \
page/Location.idl \
page/MemoryInfo.idl \
page/Navigator.idl \
page/NavigatorUserMediaError.idl \
page/NavigatorUserMediaErrorCallback.idl \
page/NavigatorUserMediaSuccessCallback.idl \
page/Performance.idl \
page/PerformanceNavigation.idl \
page/PerformanceTiming.idl \

0 comments on commit 122da8c

Please sign in to comment.