Title: [259477] trunk
Revision
259477
Author
[email protected]
Date
2020-04-03 11:22:04 -0700 (Fri, 03 Apr 2020)

Log Message

Filter some capture device names
https://bugs.webkit.org/show_bug.cgi?id=209941
<rdar://problem/59141886>

Reviewed by Youenn Fablet.

Source/WebCore:

Test: fast/mediastream/anonymize-device-name.html

* platform/mediastream/CaptureDevice.h:
(WebCore::CaptureDevice::label const):

LayoutTests:

* fast/mediastream/anonymize-device-name-expected.txt: Added.
* fast/mediastream/anonymize-device-name.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (259476 => 259477)


--- trunk/LayoutTests/ChangeLog	2020-04-03 18:06:53 UTC (rev 259476)
+++ trunk/LayoutTests/ChangeLog	2020-04-03 18:22:04 UTC (rev 259477)
@@ -1,3 +1,14 @@
+2020-04-03  Eric Carlson  <[email protected]>
+
+        Filter some capture device names
+        https://bugs.webkit.org/show_bug.cgi?id=209941
+        <rdar://problem/59141886>
+
+        Reviewed by Youenn Fablet.
+
+        * fast/mediastream/anonymize-device-name-expected.txt: Added.
+        * fast/mediastream/anonymize-device-name.html: Added.
+
 2020-04-03  Per Arne Vollan  <[email protected]>
 
         [iOS] Deny mach lookup access to the runningboard service in the WebContent process

Added: trunk/LayoutTests/fast/mediastream/anonymize-device-name-expected.txt (0 => 259477)


--- trunk/LayoutTests/fast/mediastream/anonymize-device-name-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/mediastream/anonymize-device-name-expected.txt	2020-04-03 18:22:04 UTC (rev 259477)
@@ -0,0 +1,3 @@
+
+PASS enumerateDevices() anonymizes microphone and track labels correctly 
+

Added: trunk/LayoutTests/fast/mediastream/anonymize-device-name.html (0 => 259477)


--- trunk/LayoutTests/fast/mediastream/anonymize-device-name.html	                        (rev 0)
+++ trunk/LayoutTests/fast/mediastream/anonymize-device-name.html	2020-04-03 18:22:04 UTC (rev 259477)
@@ -0,0 +1,49 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <meta charset="utf-8">
+    <script src=""
+    <script src=""
+    <script>
+    
+    promise_test(async (test) => {
+        
+        const originalLabel = "WebKit's AirPods";
+        const anonymizedLabel = "AirPods";
+
+        if (window.testRunner) {
+            testRunner.setUserMediaPermission(true);
+            testRunner.addMockMicrophoneDevice("id-1", originalLabel);
+        }
+
+        let devices = await navigator.mediaDevices.enumerateDevices();
+        for (const device of devices)
+            assert_false(!!device.label.length, "navigator.mediaDevices revealed device name before getUserMedia()");
+
+        let stream = await navigator.mediaDevices.getUserMedia({ audio:true, video:true })
+
+        for (const track of stream.getAudioTracks()) {
+            assert_false(track.label == originalLabel, "navigator.mediaDevices did not anonymize audio track label at all");
+            if (track.label.indexOf("AirPods") != -1)
+                assert_true(track.label == anonymizedLabel, "navigator.mediaDevices did not anonymize audio track label correctly");
+        }
+
+        devices = await navigator.mediaDevices.enumerateDevices();
+        const microphones = devices.filter(({kind}) => kind == "audioinput");
+        for (const microphone of microphones) {
+            const { kind, label, deviceId } = microphone;
+            if (kind != "audioinput")
+                continue;
+
+            assert_false(label == originalLabel, "navigator.mediaDevices did not anonymize microphone label at all");
+            if (label.indexOf("AirPods") != -1)
+                assert_true(label == anonymizedLabel, "navigator.mediaDevices did not anonymize microphone label correctly");
+        }
+
+    }, "enumerateDevices() anonymizes microphone and track labels correctly");
+
+    </script>
+</head>
+<body>
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (259476 => 259477)


--- trunk/Source/WebCore/ChangeLog	2020-04-03 18:06:53 UTC (rev 259476)
+++ trunk/Source/WebCore/ChangeLog	2020-04-03 18:22:04 UTC (rev 259477)
@@ -1,3 +1,16 @@
+2020-04-03  Eric Carlson  <[email protected]>
+
+        Filter some capture device names
+        https://bugs.webkit.org/show_bug.cgi?id=209941
+        <rdar://problem/59141886>
+
+        Reviewed by Youenn Fablet.
+
+        Test: fast/mediastream/anonymize-device-name.html
+
+        * platform/mediastream/CaptureDevice.h:
+        (WebCore::CaptureDevice::label const):
+
 2020-04-03  Rob Buis  <[email protected]>
 
         Remove unused parameter from loadWithNavigationAction

Modified: trunk/Source/WebCore/platform/mediastream/CaptureDevice.h (259476 => 259477)


--- trunk/Source/WebCore/platform/mediastream/CaptureDevice.h	2020-04-03 18:06:53 UTC (rev 259476)
+++ trunk/Source/WebCore/platform/mediastream/CaptureDevice.h	2020-04-03 18:22:04 UTC (rev 259477)
@@ -45,8 +45,16 @@
 
     const String& persistentId() const { return m_persistentId; }
 
-    const String& label() const { return m_label; }
+    const String& label() const
+    {
+        static NeverDestroyed<String> airPods(MAKE_STATIC_STRING_IMPL("AirPods"));
 
+        if (m_type == DeviceType::Microphone && m_label.contains(airPods))
+            return airPods;
+
+        return m_label;
+    }
+
     const String& groupId() const { return m_groupId; }
 
     DeviceType type() const { return m_type; }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to