Changeset 238724 in webkit
- Timestamp:
- Nov 29, 2018, 7:15:03 PM (8 years ago)
- Location:
- trunk
- Files:
-
- 8 edited
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/http/tests/media/media-stream/enumerate-devices-source-id-expected.txt (modified) (1 diff)
-
LayoutTests/http/tests/media/media-stream/enumerate-devices-source-id.html (modified) (3 diffs)
-
LayoutTests/http/tests/media/media-stream/resources/enumerate-devices-source-id-frame.html (modified) (2 diffs)
-
Source/WebKit/ChangeLog (modified) (1 diff)
-
Source/WebKit/UIProcess/DeviceIdHashSaltStorage.cpp (modified) (4 diffs)
-
Source/WebKit/UIProcess/DeviceIdHashSaltStorage.h (modified) (3 diffs)
-
Source/WebKit/UIProcess/UserMediaPermissionRequestManagerProxy.cpp (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r238723 r238724 1 2018-11-29 Eric Carlson <eric.carlson@apple.com> 2 3 [MediaStream] DeviceIdHashSaltStorage should use iframe and top level documents 4 https://bugs.webkit.org/show_bug.cgi?id=192182 5 6 Reviewed by Youenn Fablet. 7 8 * http/tests/media/media-stream/enumerate-devices-source-id-expected.txt: 9 * http/tests/media/media-stream/enumerate-devices-source-id.html: 10 * http/tests/media/media-stream/resources/enumerate-devices-source-id-frame.html: 11 1 12 2018-11-29 Christopher Reid <chris.reid@sony.com> 2 13 -
trunk/LayoutTests/http/tests/media/media-stream/enumerate-devices-source-id-expected.txt
r237988 r238724 2 2 3 3 4 Tests that mediaDevices.enumerateDevices returns the same value for a device ID in all subframes.4 Tests that mediaDevices.enumerateDevices returns the same ids for devices in the same frame/subframe . 5 5 6 6 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". 7 7 8 8 9 PASS : device id 1 is not unique10 PASS : device id 2 is not unique11 PASS : device id 3 is not unique12 PASS : device id 4 is not unique13 PASS : device id 5 is not unique14 PASS : device id 6 is not unique15 PASS : device id 7 is not unique16 PASS : device id 8 is not unique17 PASS : device id 9 is not unique18 PASS : device id 10 is not unique19 PASS : device id 11 is not unique20 PASS : device id 12 is not unique21 22 PASS : device IDs are not unique23 9 24 10 PASS successfullyParsed is true -
trunk/LayoutTests/http/tests/media/media-stream/enumerate-devices-source-id.html
r237988 r238724 7 7 <script src="../../../../resources/js-test-pre.js"></script> 8 8 <script> 9 var frameInfos = [];10 var idCounts = { };11 9 window.jsTestIsAsync = true; 12 10 … … 16 14 function setup() 17 15 { 18 description("Tests that mediaDevices.enumerateDevices returns the same value for a device ID in all subframes.");16 description("Tests that mediaDevices.enumerateDevices returns the same ids for devices in the same frame/subframe ."); 19 17 } 20 18 21 function handler(event) 19 let map = { }; 20 function checkID(origin, device) 22 21 { 23 event.data.deviceIds.forEach(function(id) { 24 frameInfos.push({origin : event.data.origin, deviceId : id}); 25 let count = idCounts[id] || 0; 26 idCounts[id] = ++count; 27 }); 22 let origins = `${document.origin}-${origin}`; 28 23 29 if (frameInfos.length != 12) 24 if (!map[origins]) 25 map[origins] = { }; 26 27 let originInfo = map[origins]; 28 if (!originInfo[device.deviceId]) 29 originInfo[device.deviceId] = device.kind; 30 31 if (originInfo[device.deviceId] != device.kind) 32 testFailed(`: duplicate device IDs for ${device.kind} and ${originInfo[device.deviceId]} in ${origin}/${document.origin}`); 33 34 if (Object.keys(originInfo).length > 4) 35 testFailed(`: more then four unique device IDs in ${origin}/${document.origin}`); 36 } 37 38 let eventCount = 0; 39 async function handler(event) 40 { 41 event.data.devices.forEach(device => { checkID(event.data.origin, device); }); 42 43 if (++eventCount != 6) 30 44 return; 31 45 32 var success = true; 33 for (var i = 0; i < frameInfos.length; i++) { 34 var deviceId = frameInfos[i].deviceId; 35 let count = idCounts[deviceId] || 0; 36 if (!count) { 37 testFailed(`: device id ${i + 1} is unique`); 38 success = false; 39 } else 40 testPassed(`: device id ${i + 1} is not unique`); 41 } 42 43 debug(''); 44 if (success) 45 testPassed(`: device IDs are not unique`); 46 await navigator.mediaDevices.getUserMedia({video: true, audio: true }); 47 let devices = await navigator.mediaDevices.enumerateDevices(); 48 devices.forEach(device => checkID(document.origin, device)); 46 49 47 50 debug(''); … … 54 57 </head> 55 58 <body onload="setup()"> 56 <iframe allow="camera;microphone" src="http://localhost:8000/media/media-stream/resources/enumerate-devices-source-id-frame.html "></iframe>59 <iframe allow="camera;microphone" src="http://localhost:8000/media/media-stream/resources/enumerate-devices-source-id-frame.html?1"></iframe> 57 60 <br> 58 <iframe allow="camera;microphone" src="http://127.0.0.1:8000/media/media-stream/resources/enumerate-devices-source-id-frame.html "></iframe>61 <iframe allow="camera;microphone" src="http://127.0.0.1:8000/media/media-stream/resources/enumerate-devices-source-id-frame.html?2"></iframe> 59 62 <br> 60 <iframe allow="camera;microphone" src="http://localhost:8000/media/media-stream/resources/enumerate-devices-source-id-frame.html "></iframe>63 <iframe allow="camera;microphone" src="http://localhost:8000/media/media-stream/resources/enumerate-devices-source-id-frame.html?3"></iframe> 61 64 <div id="console"></div> 62 65 <script src="../../../../resources/js-test-post.js"></script> -
trunk/LayoutTests/http/tests/media/media-stream/resources/enumerate-devices-source-id-frame.html
r197114 r238724 11 11 } 12 12 13 function test(event)13 async function test(event) 14 14 { 15 navigator.mediaDevices.enumerateDevices()16 .then(function(devices) {17 varresult = {18 origin: document.origin,19 deviceIds: [devices[0].deviceId, devices[1].deviceId]20 };15 await navigator.mediaDevices.getUserMedia({video: true, audio: true }); 16 let devices = await navigator.mediaDevices.enumerateDevices(); 17 let result = { 18 origin: document.origin, 19 devices: devices.map(device => { return {deviceId: device.deviceId, kind: device.kind} }), 20 }; 21 21 22 parent.postMessage(result, "*"); 23 }) 24 .catch(function(err) { 25 log(`enumerateDevices failed: ${err.name} - ${err.message}`); 26 }); 22 parent.postMessage(result, "*"); 27 23 28 varparentPage = document.referrer.split('/').pop();24 let parentPage = document.referrer.split('/').pop(); 29 25 if (parentPage != "enumerate-devices-source-id.html") 30 26 return; 31 27 32 variframe = document.createElement('iframe');28 let iframe = document.createElement('iframe'); 33 29 iframe.src = location.href; 34 30 document.body.appendChild(iframe); … … 37 33 function handler(event) 38 34 { 39 varresult = {40 origin: `${event.data.origin} in ${document.origin}`,41 device Ids: event.data.deviceIds35 let result = { 36 origin: `${event.data.origin}`, 37 devices: event.data.devices 42 38 }; 43 39 -
trunk/Source/WebKit/ChangeLog
r238722 r238724 1 2018-11-29 Eric Carlson <eric.carlson@apple.com> 2 3 [MediaStream] DeviceIdHashSaltStorage should use iframe and top level documents 4 https://bugs.webkit.org/show_bug.cgi?id=192182 5 6 Reviewed by Youenn Fablet. 7 8 * UIProcess/DeviceIdHashSaltStorage.cpp: 9 (WebKit::DeviceIdHashSaltStorage::deviceIdHashSaltForOrigin): Key off of request and top 10 level documents. 11 (WebKit::DeviceIdHashSaltStorage::deleteDeviceIdHashSaltForOrigins): Ditto. 12 * UIProcess/DeviceIdHashSaltStorage.h: 13 (WebKit::DeviceIdHashSaltStorage::HashSaltForOrigin::HashSaltForOrigin): 14 15 * UIProcess/UserMediaPermissionRequestManagerProxy.cpp: 16 (WebKit::UserMediaPermissionRequestManagerProxy::userMediaAccessWasGranted): Pass both documents. 17 (WebKit::UserMediaPermissionRequestManagerProxy::requestUserMediaPermissionForFrame): Ditto. 18 (WebKit::UserMediaPermissionRequestManagerProxy::enumerateMediaDevicesForFrame): Ditto. 19 1 20 2018-11-29 Ryan Haddad <ryanhaddad@apple.com> 2 21 -
trunk/Source/WebKit/UIProcess/DeviceIdHashSaltStorage.cpp
r237988 r238724 47 47 } 48 48 49 const String& DeviceIdHashSaltStorage::deviceIdHashSaltForOrigin(const SecurityOrigin& documentOrigin )49 const String& DeviceIdHashSaltStorage::deviceIdHashSaltForOrigin(const SecurityOrigin& documentOrigin, const SecurityOrigin& parentOrigin) 50 50 { 51 auto& deviceIdHashSalt = m_deviceIdHashSaltForOrigins.ensure(documentOrigin.toRawString(), [&documentOrigin] () { 51 auto origins = makeString(documentOrigin.toRawString(), parentOrigin.toRawString()); 52 auto& deviceIdHashSalt = m_deviceIdHashSaltForOrigins.ensure(origins, [&documentOrigin, &parentOrigin] () { 52 53 uint64_t randomData[randomDataSize]; 53 54 cryptographicallyRandomValues(reinterpret_cast<unsigned char*>(randomData), sizeof(randomData)); … … 56 57 builder.reserveCapacity(hashSaltSize); 57 58 for (int i = 0; i < randomDataSize; i++) 58 appendUnsigned64AsHex(randomData[ 0], builder);59 appendUnsigned64AsHex(randomData[i], builder); 59 60 60 61 String deviceIdHashSalt = builder.toString(); 61 62 62 return std::make_unique<HashSaltForOrigin>(documentOrigin.data().isolatedCopy(), WTFMove(deviceIdHashSalt));63 return std::make_unique<HashSaltForOrigin>(documentOrigin.data().isolatedCopy(), parentOrigin.data().isolatedCopy(), WTFMove(deviceIdHashSalt)); 63 64 }).iterator->value; 64 65 … … 72 73 HashSet<SecurityOriginData> origins; 73 74 74 for (auto& hashSaltForOrigin : m_deviceIdHashSaltForOrigins) 75 for (auto& hashSaltForOrigin : m_deviceIdHashSaltForOrigins) { 75 76 origins.add(hashSaltForOrigin.value->documentOrigin); 77 origins.add(hashSaltForOrigin.value->parentOrigin); 78 } 76 79 77 80 RunLoop::main().dispatch([origins = WTFMove(origins), completionHandler = WTFMove(completionHandler)]() mutable { … … 83 86 { 84 87 m_deviceIdHashSaltForOrigins.removeIf([&origins](auto& keyAndValue) { 85 return origins.contains(keyAndValue.value->documentOrigin) ;88 return origins.contains(keyAndValue.value->documentOrigin) || origins.contains(keyAndValue.value->parentOrigin); 86 89 }); 87 90 -
trunk/Source/WebKit/UIProcess/DeviceIdHashSaltStorage.h
r237988 r238724 39 39 ~DeviceIdHashSaltStorage() = default; 40 40 41 const String& deviceIdHashSaltForOrigin(const WebCore::SecurityOrigin& );41 const String& deviceIdHashSaltForOrigin(const WebCore::SecurityOrigin& documentOrigin, const WebCore::SecurityOrigin& parentOrigin); 42 42 43 43 void getDeviceIdHashSaltOrigins(CompletionHandler<void(HashSet<WebCore::SecurityOriginData>&&)>&&); … … 47 47 private: 48 48 struct HashSaltForOrigin { 49 HashSaltForOrigin(WebCore::SecurityOriginData&& securityOrigin, String&& deviceIdHashSalt) 50 : documentOrigin(securityOrigin) 49 HashSaltForOrigin(WebCore::SecurityOriginData&& documentOrigin, WebCore::SecurityOriginData&& parentOrigin, String&& deviceIdHashSalt) 50 : documentOrigin(WTFMove(documentOrigin)) 51 , parentOrigin(WTFMove(parentOrigin)) 51 52 , deviceIdHashSalt(WTFMove(deviceIdHashSalt)) 52 53 , lastTimeUsed(WallTime::now()) … … 54 55 55 56 WebCore::SecurityOriginData documentOrigin; 57 WebCore::SecurityOriginData parentOrigin; 56 58 String deviceIdHashSalt; 57 59 WallTime lastTimeUsed; -
trunk/Source/WebKit/UIProcess/UserMediaPermissionRequestManagerProxy.cpp
r237988 r238724 164 164 return; 165 165 166 auto deviceIDHashSalt = m_page.websiteDataStore().deviceIdHashSaltStorage()->deviceIdHashSaltForOrigin(request-> topLevelDocumentSecurityOrigin());166 auto deviceIDHashSalt = m_page.websiteDataStore().deviceIdHashSaltStorage()->deviceIdHashSaltForOrigin(request->userMediaDocumentSecurityOrigin(), request->topLevelDocumentSecurityOrigin()); 167 167 if (grantAccess(userMediaID, WTFMove(audioDevice), WTFMove(videoDevice), WTFMove(deviceIDHashSalt))) 168 168 m_grantedRequests.append(request.releaseNonNull()); … … 363 363 syncWithWebCorePrefs(); 364 364 365 auto deviceIDHashSalt = m_page.websiteDataStore().deviceIdHashSaltStorage()->deviceIdHashSaltForOrigin(pendingRequest.value()-> topLevelDocumentSecurityOrigin());365 auto deviceIDHashSalt = m_page.websiteDataStore().deviceIdHashSaltStorage()->deviceIdHashSaltForOrigin(pendingRequest.value()->userMediaDocumentSecurityOrigin(), pendingRequest.value()->topLevelDocumentSecurityOrigin()); 366 366 RealtimeMediaSourceCenter::singleton().validateRequestConstraints(WTFMove(validHandler), WTFMove(invalidHandler), WTFMove(localUserRequest), WTFMove(deviceIDHashSalt)); 367 367 }; … … 400 400 { 401 401 #if ENABLE(MEDIA_STREAM) 402 auto completionHandler = [this, topOrigin = topLevelDocumentOrigin.copyRef()](uint64_t userMediaID, bool originHasPersistentAccess) {402 auto completionHandler = [this, requestOrigin = userMediaDocumentOrigin.copyRef(), topOrigin = topLevelDocumentOrigin.copyRef()](uint64_t userMediaID, bool originHasPersistentAccess) { 403 403 auto pendingRequest = m_pendingDeviceRequests.take(userMediaID); 404 404 if (!pendingRequest) … … 415 415 }); 416 416 417 auto deviceIDHashSalt = m_page.websiteDataStore().deviceIdHashSaltStorage()->deviceIdHashSaltForOrigin( topOrigin.get());417 auto deviceIDHashSalt = m_page.websiteDataStore().deviceIdHashSaltStorage()->deviceIdHashSaltForOrigin(requestOrigin.get(), topOrigin.get()); 418 418 m_page.process().send(Messages::WebPage::DidCompleteMediaDeviceEnumeration(userMediaID, WTFMove(devices), WTFMove(deviceIDHashSalt), WTFMove(originHasPersistentAccess)), m_page.pageID()); 419 419 };
Note:
See TracChangeset
for help on using the changeset viewer.