Title: [225963] trunk
Revision
225963
Author
[email protected]
Date
2017-12-14 21:32:53 -0800 (Thu, 14 Dec 2017)

Log Message

Implement <iframe allow="camera; microphone">
https://bugs.webkit.org/show_bug.cgi?id=167430
LayoutTests/imported/w3c:

Patch by Youenn Fablet <[email protected]> on 2017-12-14
Reviewed by Eric Carlson.

* resources/import-expectations.json:
* web-platform-tests/feature-policy/resources/: Added as this is used for some mediacapture-streams tests.
* web-platform-tests/mediacapture-streams/: Added.

Source/WebCore:

Patch by Youenn Fablet <[email protected]> on 2017-12-14
Reviewed by Eric Carlson.

Tests: imported/w3c/web-platform-tests/mediacapture-streams/MediaStream-default-feature-policy.https.sub.html

Adding allow attribute to HTMLIFrameElement as per https://wicg.github.io/feature-policy/#iframe-allow-attribute.
Cross-origin iframes will get access to camera/microphone based on this attribute value.
Same-origin iframes do not need any attribute.
In case getUserMedia requests both camera and microphone, and allow attribute is only one of these,
getUserMedia access is denied. This goes against the tests but is not very clear from the specification.

* Modules/mediastream/UserMediaRequest.cpp:
(WebCore::isSecure):
(WebCore::isAllowedToUse):
(WebCore::canCallGetUserMedia):
(WebCore::UserMediaRequest::start):
* html/HTMLAttributeNames.in:
* html/HTMLIFrameElement.cpp:
(WebCore::HTMLIFrameElement::parseAttribute):
* html/HTMLIFrameElement.h:
* html/HTMLIFrameElement.idl:

LayoutTests:

<rdar://problem/34887226>

Patch by Youenn Fablet <[email protected]> on 2017-12-14
Reviewed by Eric Carlson.

Skipping mediastream tests for wpe.
Updating expectations based on new error message.

* TestExpectations: Skipping sync XHR test using allow attribute.
* http/tests/ssl/media-stream/get-user-media-different-host-expected.txt:
* http/tests/ssl/media-stream/get-user-media-nested-expected.txt:
* platform/mac-wk1/imported/w3c/web-platform-tests/XMLHttpRequest/xmlhttprequest-sync-default-feature-policy.sub-expected.txt:
* platform/wpe/TestExpectations:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (225962 => 225963)


--- trunk/LayoutTests/ChangeLog	2017-12-15 05:22:36 UTC (rev 225962)
+++ trunk/LayoutTests/ChangeLog	2017-12-15 05:32:53 UTC (rev 225963)
@@ -1,3 +1,20 @@
+2017-12-14  Youenn Fablet  <[email protected]>
+
+        Implement <iframe allow="camera; microphone">
+        https://bugs.webkit.org/show_bug.cgi?id=167430
+        <rdar://problem/34887226>
+
+        Reviewed by Eric Carlson.
+
+        Skipping mediastream tests for wpe.
+        Updating expectations based on new error message.
+
+        * TestExpectations: Skipping sync XHR test using allow attribute.
+        * http/tests/ssl/media-stream/get-user-media-different-host-expected.txt:
+        * http/tests/ssl/media-stream/get-user-media-nested-expected.txt:
+        * platform/mac-wk1/imported/w3c/web-platform-tests/XMLHttpRequest/xmlhttprequest-sync-default-feature-policy.sub-expected.txt:
+        * platform/wpe/TestExpectations:
+
 2017-12-14  Zalan Bujtas  <[email protected]>
 
         Inconsistent section grid could lead to CrashOnOverflow

Modified: trunk/LayoutTests/TestExpectations (225962 => 225963)


--- trunk/LayoutTests/TestExpectations	2017-12-15 05:22:36 UTC (rev 225962)
+++ trunk/LayoutTests/TestExpectations	2017-12-15 05:32:53 UTC (rev 225963)
@@ -222,6 +222,7 @@
 imported/w3c/web-platform-tests/payment-request [ Skip ]
 
 imported/w3c/web-platform-tests/2dcontext/transformations/canvas_transformations_reset_001.html [ ImageOnlyFailure ]
+imported/w3c/web-platform-tests/XMLHttpRequest/xmlhttprequest-sync-default-feature-policy.sub.html [ Skip ]
 webkit.org/b/179607 imported/w3c/web-platform-tests/XMLHttpRequest/access-control-and-redirects-async.htm [ Pass Failure ]
 webkit.org/b/179607 imported/w3c/web-platform-tests/XMLHttpRequest/access-control-and-redirects-async-same-origin.htm [ Pass Failure ]
 webkit.org/b/179608 imported/w3c/web-platform-tests/XMLHttpRequest/access-control-preflight-async-header-denied.htm [ Failure ]

Modified: trunk/LayoutTests/http/tests/ssl/media-stream/get-user-media-different-host-expected.txt (225962 => 225963)


--- trunk/LayoutTests/http/tests/ssl/media-stream/get-user-media-different-host-expected.txt	2017-12-15 05:22:36 UTC (rev 225962)
+++ trunk/LayoutTests/http/tests/ssl/media-stream/get-user-media-different-host-expected.txt	2017-12-15 05:32:53 UTC (rev 225963)
@@ -1,4 +1,4 @@
-CONSOLE MESSAGE: line 52: Trying to call getUserMedia from a document with a different security origin than its top-level frame.
+CONSOLE MESSAGE: line 52: The top-level frame has prevented a document with a different security origin to call getUserMedia.
 Tests that getUserMedia fails when the top level document and iframe do not have the same domain.
 
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".

Modified: trunk/LayoutTests/http/tests/ssl/media-stream/get-user-media-nested-expected.txt (225962 => 225963)


--- trunk/LayoutTests/http/tests/ssl/media-stream/get-user-media-nested-expected.txt	2017-12-15 05:22:36 UTC (rev 225962)
+++ trunk/LayoutTests/http/tests/ssl/media-stream/get-user-media-nested-expected.txt	2017-12-15 05:32:53 UTC (rev 225963)
@@ -1,4 +1,4 @@
-CONSOLE MESSAGE: line 52: Trying to call getUserMedia from a document with a different security origin than its top-level frame.
+CONSOLE MESSAGE: line 52: The top-level frame has prevented a document with a different security origin to call getUserMedia.
 Tests that getUserMedia fails when the top level document and iframe do not have the same domain.
 
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (225962 => 225963)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2017-12-15 05:22:36 UTC (rev 225962)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2017-12-15 05:32:53 UTC (rev 225963)
@@ -1,3 +1,14 @@
+2017-12-14  Youenn Fablet  <[email protected]>
+
+        Implement <iframe allow="camera; microphone">
+        https://bugs.webkit.org/show_bug.cgi?id=167430
+
+        Reviewed by Eric Carlson.
+
+        * resources/import-expectations.json:
+        * web-platform-tests/feature-policy/resources/: Added as this is used for some mediacapture-streams tests.
+        * web-platform-tests/mediacapture-streams/: Added.
+
 2017-12-14  Chris Dumez  <[email protected]>
 
         Unreviewed, commit missing empty.js file in service workers WPT tests

Modified: trunk/LayoutTests/imported/w3c/resources/import-expectations.json (225962 => 225963)


--- trunk/LayoutTests/imported/w3c/resources/import-expectations.json	2017-12-15 05:22:36 UTC (rev 225962)
+++ trunk/LayoutTests/imported/w3c/resources/import-expectations.json	2017-12-15 05:32:53 UTC (rev 225963)
@@ -134,6 +134,7 @@
     "web-platform-tests/ext-xhtml-pubid": "skip", 
     "web-platform-tests/feature-policy": "skip", 
     "web-platform-tests/feature-policy/resources": "import", 
+    "web-platform-tests/feature-policy/resources/": "import", 
     "web-platform-tests/fetch": "import", 
     "web-platform-tests/fullscreen": "skip", 
     "web-platform-tests/gamepad": "skip", 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/XMLHttpRequest/xmlhttprequest-sync-default-feature-policy.sub-expected.txt (225962 => 225963)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/XMLHttpRequest/xmlhttprequest-sync-default-feature-policy.sub-expected.txt	2017-12-15 05:22:36 UTC (rev 225962)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/XMLHttpRequest/xmlhttprequest-sync-default-feature-policy.sub-expected.txt	2017-12-15 05:32:53 UTC (rev 225963)
@@ -1,4 +1,5 @@
 Blocked access to external URL http://www.localhost:8800/XMLHttpRequest/xmlhttprequest-sync-default-feature-policy.sub.html#iframe#sync-xhr
+Blocked access to external URL http://www.localhost:8800/XMLHttpRequest/xmlhttprequest-sync-default-feature-policy.sub.html#iframe#sync-xhr
 
 
 Harness Error (TIMEOUT), message = null
@@ -6,5 +7,5 @@
 PASS Default "sync-xhr" feature policy ["*"] allows the top-level document. 
 PASS Default "sync-xhr" feature policy ["*"] allows same-origin iframes. 
 TIMEOUT Default "sync-xhr" feature policy ["*"] allows cross-origin iframes. Test timed out
-FAIL Feature policy "sync-xhr" can be disabled in cross-origin iframes using "allow" attribute. undefined is not an object (evaluating 'frame.allow.concat')
+TIMEOUT Feature policy "sync-xhr" can be disabled in cross-origin iframes using "allow" attribute. Test timed out
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/feature-policy/resources/featurepolicy.js (225962 => 225963)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/feature-policy/resources/featurepolicy.js	2017-12-15 05:22:36 UTC (rev 225962)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/feature-policy/resources/featurepolicy.js	2017-12-15 05:32:53 UTC (rev 225963)
@@ -81,7 +81,7 @@
   if (location.hash.includes(feature_name)) {
     feature_promise_factory().then(
         () => window.parent.postMessage('#OK', '*'),
-        (e) => window.parent.postMessage('#' + e.toString(), '*'));
+        (e) => window.parent.postMessage('#' + e.name, '*'));
   }
 }
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/feature-policy/resources/w3c-import.log (225962 => 225963)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/feature-policy/resources/w3c-import.log	2017-12-15 05:22:36 UTC (rev 225962)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/feature-policy/resources/w3c-import.log	2017-12-15 05:32:53 UTC (rev 225963)
@@ -14,8 +14,12 @@
 None
 ------------------------------------------------------------------------
 List of files:
+/LayoutTests/imported/w3c/web-platform-tests/feature-policy/resources/autoplay.js
+/LayoutTests/imported/w3c/web-platform-tests/feature-policy/resources/feature-policy-autoplay.html
+/LayoutTests/imported/w3c/web-platform-tests/feature-policy/resources/feature-policy-generic-sensor.html
 /LayoutTests/imported/w3c/web-platform-tests/feature-policy/resources/feature-policy-payment.html
 /LayoutTests/imported/w3c/web-platform-tests/feature-policy/resources/feature-policy-usb.html
+/LayoutTests/imported/w3c/web-platform-tests/feature-policy/resources/feature-policy-wakelock.html
 /LayoutTests/imported/w3c/web-platform-tests/feature-policy/resources/feature-policy-webvr.html
 /LayoutTests/imported/w3c/web-platform-tests/feature-policy/resources/featurepolicy.js
 /LayoutTests/imported/w3c/web-platform-tests/feature-policy/resources/redirect-on-load.html

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/mediacapture-streams/MediaStream-default-feature-policy.https-expected.txt (225962 => 225963)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/mediacapture-streams/MediaStream-default-feature-policy.https-expected.txt	2017-12-15 05:22:36 UTC (rev 225962)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/mediacapture-streams/MediaStream-default-feature-policy.https-expected.txt	2017-12-15 05:32:53 UTC (rev 225963)
@@ -1,20 +1,22 @@
-CONSOLE MESSAGE: line 1: Trying to call getUserMedia from a document with a different security origin than its top-level frame.
-CONSOLE MESSAGE: line 1: Trying to call getUserMedia from a document with a different security origin than its top-level frame.
-CONSOLE MESSAGE: line 1: Trying to call getUserMedia from a document with a different security origin than its top-level frame.
-CONSOLE MESSAGE: line 1: Trying to call getUserMedia from a document with a different security origin than its top-level frame.
-CONSOLE MESSAGE: line 1: Trying to call getUserMedia from a document with a different security origin than its top-level frame.
+CONSOLE MESSAGE: line 1: The top-level frame has prevented a document with a different security origin to call getUserMedia.
+CONSOLE MESSAGE: line 1: The top-level frame has prevented a document with a different security origin to call getUserMedia.
+CONSOLE MESSAGE: line 1: The top-level frame has prevented a document with a different security origin to call getUserMedia.
+CONSOLE MESSAGE: line 1: The top-level frame has prevented a document with a different security origin to call getUserMedia.
+CONSOLE MESSAGE: line 1: The top-level frame has prevented a document with a different security origin to call getUserMedia.
+CONSOLE MESSAGE: line 1: The top-level frame has prevented a document with a different security origin to call getUserMedia.
+CONSOLE MESSAGE: line 1: The top-level frame has prevented a document with a different security origin to call getUserMedia.
 
 
 PASS Default "microphone" feature policy ["self"] allows the top-level document. 
 PASS Default "microphone" feature policy ["self"] allows same-origin iframes. 
-FAIL Default "microphone" feature policy ["self"] disallows cross-origin iframes. assert_equals: expected "#[object NavigatorUserMediaError]" but got "#NotAllowedError: The request is not allowed by the user agent or the platform in the current context, possibly because the user denied permission."
-FAIL Feature policy "microphone" can be enabled in cross-origin iframes using "allow" attribute. undefined is not an object (evaluating 'frame.allow.concat')
+PASS Default "microphone" feature policy ["self"] disallows cross-origin iframes. 
+FAIL Feature policy "microphone" can be enabled in cross-origin iframes using "allow" attribute. assert_equals: expected "#OK" but got "#NotAllowedError"
 PASS Default "camera" feature policy ["self"] allows the top-level document. 
 PASS Default "camera" feature policy ["self"] allows same-origin iframes. 
-FAIL Default "camera" feature policy ["self"] disallows cross-origin iframes. assert_equals: expected "#[object NavigatorUserMediaError]" but got "#NotAllowedError: The request is not allowed by the user agent or the platform in the current context, possibly because the user denied permission."
-FAIL Feature policy "camera" can be enabled in cross-origin iframes using "allow" attribute. undefined is not an object (evaluating 'frame.allow.concat')
+PASS Default "camera" feature policy ["self"] disallows cross-origin iframes. 
+FAIL Feature policy "camera" can be enabled in cross-origin iframes using "allow" attribute. assert_equals: expected "#OK" but got "#NotAllowedError"
 PASS Default "camera; microphone" feature policy ["self"] allows the top-level document. 
 PASS Default "camera; microphone" feature policy ["self"] allows same-origin iframes. 
-FAIL Default "camera; microphone" feature policy ["self"] disallows cross-origin iframes. assert_equals: expected "#[object NavigatorUserMediaError]" but got "#NotAllowedError: The request is not allowed by the user agent or the platform in the current context, possibly because the user denied permission."
-FAIL Feature policy "camera; microphone" can be enabled in cross-origin iframes using "allow" attribute. undefined is not an object (evaluating 'frame.allow.concat')
+PASS Default "camera; microphone" feature policy ["self"] disallows cross-origin iframes. 
+PASS Feature policy "camera; microphone" can be enabled in cross-origin iframes using "allow" attribute. 
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/mediacapture-streams/MediaStream-default-feature-policy.https.html (225962 => 225963)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/mediacapture-streams/MediaStream-default-feature-policy.https.html	2017-12-15 05:22:36 UTC (rev 225962)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/mediacapture-streams/MediaStream-default-feature-policy.https.html	2017-12-15 05:32:53 UTC (rev 225963)
@@ -37,7 +37,7 @@
   run_all_fp_tests_allow_self(
       cross_domain,
       'microphone',
-      '[object NavigatorUserMediaError]',
+      'NotAllowedError',
       function() {
         return promise_factory('microphone');
       });
@@ -45,7 +45,7 @@
   run_all_fp_tests_allow_self(
       cross_domain,
       'camera',
-      '[object NavigatorUserMediaError]',
+      'NotAllowedError',
       function() {
         return promise_factory('camera');
       });
@@ -53,7 +53,7 @@
   run_all_fp_tests_allow_self(
     cross_domain,
     'camera; microphone',
-    '[object NavigatorUserMediaError]',
+    'NotAllowedError',
     function() {
       return promise_factory('camera; microphone');
     });

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/mediacapture-streams/MediaStreamTrack-init.https-expected.txt (225962 => 225963)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/mediacapture-streams/MediaStreamTrack-init.https-expected.txt	2017-12-15 05:22:36 UTC (rev 225962)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/mediacapture-streams/MediaStreamTrack-init.https-expected.txt	2017-12-15 05:32:53 UTC (rev 225963)
@@ -5,59 +5,5 @@
 This test checks that the video track of MediaStream object returned by the success callback in getUserMedia is correctly initialized.
 
 
-PASS Tests that the video MediaStreamTrack objects are properly initialized 
-PASS EventTarget interface: existence and properties of interface object 
-PASS EventTarget interface object length 
-PASS EventTarget interface object name 
-PASS EventTarget interface: existence and properties of interface prototype object 
-PASS EventTarget interface: existence and properties of interface prototype object's "constructor" property 
-PASS EventTarget interface: operation addEventListener(DOMString, EventListener, boolean) 
-PASS EventTarget interface: operation removeEventListener(DOMString, EventListener, boolean) 
-PASS EventTarget interface: operation dispatchEvent(Event) 
-PASS MediaStreamTrack interface: existence and properties of interface object 
-PASS MediaStreamTrack interface object length 
-PASS MediaStreamTrack interface object name 
-PASS MediaStreamTrack interface: existence and properties of interface prototype object 
-PASS MediaStreamTrack interface: existence and properties of interface prototype object's "constructor" property 
-PASS MediaStreamTrack interface: attribute kind 
-PASS MediaStreamTrack interface: attribute id 
-PASS MediaStreamTrack interface: attribute label 
-PASS MediaStreamTrack interface: attribute enabled 
-PASS MediaStreamTrack interface: attribute muted 
-PASS MediaStreamTrack interface: attribute onmute 
-PASS MediaStreamTrack interface: attribute onunmute 
-PASS MediaStreamTrack interface: attribute readyState 
-PASS MediaStreamTrack interface: attribute onended 
-PASS MediaStreamTrack interface: attribute onoverconstrained 
-PASS MediaStreamTrack interface: operation clone() 
-PASS MediaStreamTrack interface: operation stop() 
-PASS MediaStreamTrack interface: operation getCapabilities() 
-PASS MediaStreamTrack interface: operation getConstraints() 
-PASS MediaStreamTrack interface: operation getSettings() 
-PASS MediaStreamTrack interface: operation applyConstraints(MediaTrackConstraints) 
-PASS MediaStreamTrack must be primary interface of track 
-PASS Stringification of track 
-PASS MediaStreamTrack interface: track must inherit property "kind" with the proper type 
-PASS MediaStreamTrack interface: track must inherit property "id" with the proper type 
-PASS MediaStreamTrack interface: track must inherit property "label" with the proper type 
-PASS MediaStreamTrack interface: track must inherit property "enabled" with the proper type 
-PASS MediaStreamTrack interface: track must inherit property "muted" with the proper type 
-FAIL MediaStreamTrack interface: track must inherit property "onmute" with the proper type Unrecognized type EventHandler
-FAIL MediaStreamTrack interface: track must inherit property "onunmute" with the proper type Unrecognized type EventHandler
-FAIL MediaStreamTrack interface: track must inherit property "readyState" with the proper type Unrecognized type MediaStreamTrackState
-FAIL MediaStreamTrack interface: track must inherit property "onended" with the proper type Unrecognized type EventHandler
-FAIL MediaStreamTrack interface: track must inherit property "onoverconstrained" with the proper type Unrecognized type EventHandler
-PASS MediaStreamTrack interface: track must inherit property "clone()" with the proper type 
-PASS MediaStreamTrack interface: track must inherit property "stop()" with the proper type 
-PASS MediaStreamTrack interface: track must inherit property "getCapabilities()" with the proper type 
-PASS MediaStreamTrack interface: track must inherit property "getConstraints()" with the proper type 
-PASS MediaStreamTrack interface: track must inherit property "getSettings()" with the proper type 
-PASS MediaStreamTrack interface: track must inherit property "applyConstraints(MediaTrackConstraints)" with the proper type 
-PASS MediaStreamTrack interface: calling applyConstraints(MediaTrackConstraints) on track with too few arguments must throw TypeError 
-PASS EventTarget interface: track must inherit property "addEventListener(DOMString, EventListener, boolean)" with the proper type 
-PASS EventTarget interface: calling addEventListener(DOMString, EventListener, boolean) on track with too few arguments must throw TypeError 
-PASS EventTarget interface: track must inherit property "removeEventListener(DOMString, EventListener, boolean)" with the proper type 
-PASS EventTarget interface: calling removeEventListener(DOMString, EventListener, boolean) on track with too few arguments must throw TypeError 
-PASS EventTarget interface: track must inherit property "dispatchEvent(Event)" with the proper type 
-PASS EventTarget interface: calling dispatchEvent(Event) on track with too few arguments must throw TypeError 
+PASS getUserMedia({video:true}) creates a stream with a properly initialized video track 
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/mediacapture-streams/MediaStreamTrack-init.https.html (225962 => 225963)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/mediacapture-streams/MediaStreamTrack-init.https.html	2017-12-15 05:22:36 UTC (rev 225962)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/mediacapture-streams/MediaStreamTrack-init.https.html	2017-12-15 05:32:53 UTC (rev 225963)
@@ -18,53 +18,19 @@
 <div id='log'></div>
 <script src=""
 <script src=""
-<script src=""
-<script src=""
 <script>
-var t = async_test("Tests that the video MediaStreamTrack objects are properly initialized", {timeout:10000});
-var track = null
-var idl_array = new IdlArray();
-
-idl_array.add_idls("interface EventTarget {\
-  void addEventListener(DOMString type, EventListener? callback, optional boolean capture = false);\
-  void removeEventListener(DOMString type, EventListener? callback, optional boolean capture = false);\
-  boolean dispatchEvent(Event event);\
-};");
-
-idl_array.add_idls("interface MediaStreamTrack : EventTarget {\
-    readonly    attribute DOMString             kind;\
-    readonly    attribute DOMString             id;\
-    readonly    attribute DOMString             label;\
-                attribute boolean               enabled;\
-    readonly    attribute boolean               muted;\
-                attribute EventHandler          onmute;\
-                attribute EventHandler          onunmute;\
-    readonly    attribute MediaStreamTrackState readyState;\
-                attribute EventHandler          onended;\
-                attribute EventHandler          onoverconstrained;\
-    MediaStreamTrack       clone ();\
-    void                   stop ();\
-    MediaTrackCapabilities getCapabilities ();\
-    MediaTrackConstraints  getConstraints ();\
-    MediaTrackSettings     getSettings ();\
-    Promise<void>          applyConstraints (optional MediaTrackConstraints constraints);\
-};");
-
-t.step(function () {
-  navigator.mediaDevices.getUserMedia({video: true})
-    .then(t.step_func(function (stream) {
+promise_test(() => {
+  return navigator.mediaDevices.getUserMedia({video: true})
+    .then(stream => {
       var videoTracks = stream.getVideoTracks();
       assert_equals(videoTracks.length, 1, "There is exactly one video track in the media stream");
       track = videoTracks[0];
-      idl_array.add_objects({MediaStreamTrack: ["track"]});
-      idl_array.test();
       assert_equals(track.readyState, "live", "The track object is in live state");
       assert_equals(track.kind, "video", "The track object is of video kind");
       // Not clear that this is required by the spec,
       // see https://www.w3.org/Bugs/Public/show_bug.cgi?id=22212
       assert_true(track.enabled, "The track object is enabed");
-      t.done();
-    }));
+    });
 });
 </script>
 </body>

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/mediacapture-streams/OWNERS (225962 => 225963)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/mediacapture-streams/OWNERS	2017-12-15 05:22:36 UTC (rev 225962)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/mediacapture-streams/OWNERS	2017-12-15 05:32:53 UTC (rev 225963)
@@ -1,4 +1,5 @@
 @agouaillard
 @alvestrand
 @dontcallmedom
+@eric-carlson
 @youennf

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/mediacapture-streams/w3c-import.log (225962 => 225963)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/mediacapture-streams/w3c-import.log	2017-12-15 05:22:36 UTC (rev 225962)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/mediacapture-streams/w3c-import.log	2017-12-15 05:32:53 UTC (rev 225963)
@@ -41,6 +41,7 @@
 /LayoutTests/imported/w3c/web-platform-tests/mediacapture-streams/MediaStreamTrack-end-manual.https.html
 /LayoutTests/imported/w3c/web-platform-tests/mediacapture-streams/MediaStreamTrack-getSettings.https.html
 /LayoutTests/imported/w3c/web-platform-tests/mediacapture-streams/MediaStreamTrack-id.https.html
+/LayoutTests/imported/w3c/web-platform-tests/mediacapture-streams/MediaStreamTrack-idl.https.html
 /LayoutTests/imported/w3c/web-platform-tests/mediacapture-streams/MediaStreamTrack-init.https.html
 /LayoutTests/imported/w3c/web-platform-tests/mediacapture-streams/MediaStreamTrackEvent-constructor.https.html
 /LayoutTests/imported/w3c/web-platform-tests/mediacapture-streams/OWNERS

Modified: trunk/LayoutTests/platform/mac-wk1/imported/w3c/web-platform-tests/XMLHttpRequest/xmlhttprequest-sync-default-feature-policy.sub-expected.txt (225962 => 225963)


--- trunk/LayoutTests/platform/mac-wk1/imported/w3c/web-platform-tests/XMLHttpRequest/xmlhttprequest-sync-default-feature-policy.sub-expected.txt	2017-12-15 05:22:36 UTC (rev 225962)
+++ trunk/LayoutTests/platform/mac-wk1/imported/w3c/web-platform-tests/XMLHttpRequest/xmlhttprequest-sync-default-feature-policy.sub-expected.txt	2017-12-15 05:32:53 UTC (rev 225963)
@@ -1,4 +1,5 @@
 Blocked access to external URL http://www.localhost:8800/XMLHttpRequest/xmlhttprequest-sync-default-feature-policy.sub.html#iframe%23sync-xhr
+Blocked access to external URL http://www.localhost:8800/XMLHttpRequest/xmlhttprequest-sync-default-feature-policy.sub.html#iframe%23sync-xhr
 
 
 Harness Error (TIMEOUT), message = null
@@ -6,5 +7,5 @@
 PASS Default "sync-xhr" feature policy ["*"] allows the top-level document. 
 PASS Default "sync-xhr" feature policy ["*"] allows same-origin iframes. 
 TIMEOUT Default "sync-xhr" feature policy ["*"] allows cross-origin iframes. Test timed out
-FAIL Feature policy "sync-xhr" can be disabled in cross-origin iframes using "allow" attribute. undefined is not an object (evaluating 'frame.allow.concat')
+TIMEOUT Feature policy "sync-xhr" can be disabled in cross-origin iframes using "allow" attribute. Test timed out
 

Modified: trunk/LayoutTests/platform/wpe/TestExpectations (225962 => 225963)


--- trunk/LayoutTests/platform/wpe/TestExpectations	2017-12-15 05:22:36 UTC (rev 225962)
+++ trunk/LayoutTests/platform/wpe/TestExpectations	2017-12-15 05:32:53 UTC (rev 225963)
@@ -424,6 +424,7 @@
 Bug(WPE) fast/media [ Skip ]
 Bug(WPE) fast/mediacapturefromelement [ Skip ]
 Bug(WPE) fast/mediastream [ Skip ]
+imported/w3c/web-platform-tests/mediacapture-streams [ Skip ]
 Bug(WPE) fast/multicol [ Skip ]
 Bug(WPE) fast/overflow [ Skip ]
 Bug(WPE) fast/picture [ Skip ]

Modified: trunk/Source/WebCore/ChangeLog (225962 => 225963)


--- trunk/Source/WebCore/ChangeLog	2017-12-15 05:22:36 UTC (rev 225962)
+++ trunk/Source/WebCore/ChangeLog	2017-12-15 05:32:53 UTC (rev 225963)
@@ -1,3 +1,29 @@
+2017-12-14  Youenn Fablet  <[email protected]>
+
+        Implement <iframe allow="camera; microphone">
+        https://bugs.webkit.org/show_bug.cgi?id=167430
+
+        Reviewed by Eric Carlson.
+
+        Tests: imported/w3c/web-platform-tests/mediacapture-streams/MediaStream-default-feature-policy.https.sub.html
+
+        Adding allow attribute to HTMLIFrameElement as per https://wicg.github.io/feature-policy/#iframe-allow-attribute.
+        Cross-origin iframes will get access to camera/microphone based on this attribute value.
+        Same-origin iframes do not need any attribute.
+        In case getUserMedia requests both camera and microphone, and allow attribute is only one of these,
+        getUserMedia access is denied. This goes against the tests but is not very clear from the specification.
+
+        * Modules/mediastream/UserMediaRequest.cpp:
+        (WebCore::isSecure):
+        (WebCore::isAllowedToUse):
+        (WebCore::canCallGetUserMedia):
+        (WebCore::UserMediaRequest::start):
+        * html/HTMLAttributeNames.in:
+        * html/HTMLIFrameElement.cpp:
+        (WebCore::HTMLIFrameElement::parseAttribute):
+        * html/HTMLIFrameElement.h:
+        * html/HTMLIFrameElement.idl:
+
 2017-12-14  Zalan Bujtas  <[email protected]>
 
         Inconsistent section grid could lead to CrashOnOverflow

Modified: trunk/Source/WebCore/Modules/mediastream/UserMediaRequest.cpp (225962 => 225963)


--- trunk/Source/WebCore/Modules/mediastream/UserMediaRequest.cpp	2017-12-15 05:22:36 UTC (rev 225962)
+++ trunk/Source/WebCore/Modules/mediastream/UserMediaRequest.cpp	2017-12-15 05:32:53 UTC (rev 225963)
@@ -40,6 +40,8 @@
 #include "DeprecatedGlobalSettings.h"
 #include "Document.h"
 #include "DocumentLoader.h"
+#include "HTMLIFrameElement.h"
+#include "HTMLParserIdioms.h"
 #include "JSMediaStream.h"
 #include "JSOverconstrainedError.h"
 #include "Logging.h"
@@ -95,16 +97,51 @@
 static bool isSecure(DocumentLoader& documentLoader)
 {
     auto& response = documentLoader.response();
+    if (SecurityOrigin::isLocalHostOrLoopbackIPAddress(documentLoader.response().url()))
+        return true;
     return SchemeRegistry::shouldTreatURLSchemeAsSecure(response.url().protocol().toStringWithoutCopying())
         && response.certificateInfo()
         && !response.certificateInfo()->containsNonRootSHA1SignedCertificate();
 }
 
-static bool canCallGetUserMedia(Document& document, String& errorMessage)
+static bool isAllowedToUse(Document& document, Document& topDocument, bool requiresAudio, bool requiresVideo)
 {
+    if (&document == &topDocument)
+        return true;
+
+    auto* parentDocument = document.parentDocument();
+    if (!parentDocument)
+        return false;
+
+    if (document.securityOrigin().isSameSchemeHostPort(parentDocument->securityOrigin()))
+        return true;
+
+    auto* element = document.ownerElement();
+    ASSERT(element);
+    if (!element)
+        return false;
+
+    if (!is<HTMLIFrameElement>(*element))
+        return false;
+    auto& allow = downcast<HTMLIFrameElement>(*element).allow();
+
+    bool allowCameraAccess = false;
+    bool allowMicrophoneAccess = false;
+    for (auto allowItem : StringView { allow }.split(';')) {
+        auto item = allowItem.stripLeadingAndTrailingMatchedCharacters(isHTMLSpace<UChar>);
+        if (!allowCameraAccess && item == "camera")
+            allowCameraAccess = true;
+        else if (!allowMicrophoneAccess && item == "microphone")
+            allowMicrophoneAccess = true;
+    }
+    return (allowCameraAccess || !requiresVideo) && (allowMicrophoneAccess || !requiresAudio);
+}
+
+static bool canCallGetUserMedia(Document& document, bool wantsAudio, bool wantsVideo, String& errorMessage)
+{
     bool requiresSecureConnection = DeprecatedGlobalSettings::mediaCaptureRequiresSecureConnection();
     auto& documentLoader = *document.loader();
-    if (requiresSecureConnection && !isSecure(documentLoader) && !SecurityOrigin::isLocalHostOrLoopbackIPAddress(documentLoader.response().url())) {
+    if (requiresSecureConnection && !isSecure(documentLoader)) {
         errorMessage = "Trying to call getUserMedia from an insecure document.";
         return false;
     }
@@ -111,21 +148,14 @@
 
     auto& topDocument = document.topDocument();
     if (&document != &topDocument) {
-        auto& topOrigin = topDocument.topOrigin();
-
-        if (!document.securityOrigin().isSameSchemeHostPort(topOrigin)) {
-            errorMessage = "Trying to call getUserMedia from a document with a different security origin than its top-level frame.";
-            return false;
-        }
-
-        for (auto* ancestorDocument = document.parentDocument(); ancestorDocument != &topDocument; ancestorDocument = ancestorDocument->parentDocument()) {
+        for (auto* ancestorDocument = &document; ancestorDocument != &topDocument; ancestorDocument = ancestorDocument->parentDocument()) {
             if (requiresSecureConnection && !isSecure(*ancestorDocument->loader())) {
                 errorMessage = "Trying to call getUserMedia from a document with an insecure parent frame.";
                 return false;
             }
 
-            if (!ancestorDocument->securityOrigin().isSameSchemeHostPort(topOrigin)) {
-                errorMessage = "Trying to call getUserMedia from a document with a different security origin than its top-level frame.";
+            if (!isAllowedToUse(*ancestorDocument, topDocument, wantsAudio, wantsVideo)) {
+                errorMessage = "The top-level frame has prevented a document with a different security origin to call getUserMedia.";
                 return false;
             }
         }
@@ -146,7 +176,7 @@
     // 10.2 - 6.3 Optionally, e.g., based on a previously-established user preference, for security reasons,
     // or due to platform limitations, jump to the step labeled Permission Failure below.
     String errorMessage;
-    if (!canCallGetUserMedia(document, errorMessage)) {
+    if (!canCallGetUserMedia(document, m_audioConstraints.isValid, m_videoConstraints.isValid, errorMessage)) {
         deny(MediaAccessDenialReason::PermissionDenied, emptyString());
         document.domWindow()->printErrorMessage(errorMessage);
         return;

Modified: trunk/Source/WebCore/html/HTMLAttributeNames.in (225962 => 225963)


--- trunk/Source/WebCore/html/HTMLAttributeNames.in	2017-12-15 05:22:36 UTC (rev 225962)
+++ trunk/Source/WebCore/html/HTMLAttributeNames.in	2017-12-15 05:32:53 UTC (rev 225963)
@@ -10,6 +10,7 @@
 action
 align
 alink
+allow
 allowfullscreen
 alt
 archive

Modified: trunk/Source/WebCore/html/HTMLIFrameElement.cpp (225962 => 225963)


--- trunk/Source/WebCore/html/HTMLIFrameElement.cpp	2017-12-15 05:22:36 UTC (rev 225962)
+++ trunk/Source/WebCore/html/HTMLIFrameElement.cpp	2017-12-15 05:32:53 UTC (rev 225963)
@@ -93,7 +93,9 @@
         setSandboxFlags(value.isNull() ? SandboxNone : SecurityContext::parseSandboxPolicy(value, invalidTokens));
         if (!invalidTokens.isNull())
             document().addConsoleMessage(MessageSource::Other, MessageLevel::Error, "Error while parsing the 'sandbox' attribute: " + invalidTokens);
-    } else
+    } else if (name == allowAttr)
+        m_allow = value;
+    else
         HTMLFrameElementBase::parseAttribute(name, value);
 }
 

Modified: trunk/Source/WebCore/html/HTMLIFrameElement.h (225962 => 225963)


--- trunk/Source/WebCore/html/HTMLIFrameElement.h	2017-12-15 05:22:36 UTC (rev 225962)
+++ trunk/Source/WebCore/html/HTMLIFrameElement.h	2017-12-15 05:32:53 UTC (rev 225963)
@@ -37,6 +37,7 @@
     DOMTokenList& sandbox();
 
     RenderIFrame* renderer() const;
+    const String& allow() const { return m_allow; }
 
 private:
     HTMLIFrameElement(const QualifiedName&, Document&);
@@ -53,6 +54,7 @@
     RenderPtr<RenderElement> createElementRenderer(RenderStyle&&, const RenderTreePosition&) final;
 
     std::unique_ptr<DOMTokenList> m_sandbox;
+    String m_allow;
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/html/HTMLIFrameElement.idl (225962 => 225963)


--- trunk/Source/WebCore/html/HTMLIFrameElement.idl	2017-12-15 05:22:36 UTC (rev 225962)
+++ trunk/Source/WebCore/html/HTMLIFrameElement.idl	2017-12-15 05:32:53 UTC (rev 225963)
@@ -29,6 +29,7 @@
 
     [PutForwards=value] readonly attribute DOMTokenList sandbox;
     [Reflect] attribute boolean allowFullscreen;
+    [CEReactions, Reflect] attribute DOMString allow;
 
     [Reflect] attribute DOMString scrolling;
     [Reflect, URL] attribute USVString src;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to