| <!DOCTYPE html> |
| <html> |
| <head> |
| <style> |
| iframe { border: 1px solid black; } |
| </style> |
| <script src="../../../../resources/js-test-pre.js"></script> |
| <script> |
| var frameInfos = []; |
| var idCounts = new Map(); |
| window.jsTestIsAsync = true; |
| |
| if (window.testRunner) { |
| testRunner.setUserMediaPermission(true); |
| testRunner.setUserMediaPersistentPermissionForOrigin(true, "http://localhost:8000", location.href); |
| } |
| |
| function setup() |
| { |
| description("Tests that mediaDevices.enumerateDevices returns a persistent deviceId when appropriate." |
| + "<br>http://localhost:8000 has persistent permission, so IDs must persist across frames."); |
| } |
| |
| function handler(event) |
| { |
| event.data.deviceIds.forEach(function(id) { |
| frameInfos.push({origin : event.data.origin, deviceId : id}); |
| if (idCounts.has(id)) |
| idCounts.set(id, idCounts.get(id) + 1); |
| else |
| idCounts.set(id, 1); |
| }); |
| |
| if (frameInfos.length != 6) |
| return; |
| |
| var success = true; |
| for (var i = 0; i < frameInfos.length; i++) { |
| var deviceId = frameInfos[i].deviceId; |
| if (frameInfos[i].origin.indexOf("http://localhost:8000") == 0) { |
| if (idCounts.get(deviceId) < 2) { |
| testFailed(`: device ID in ${frameInfos[i].origin} is unique`); |
| success = false; |
| } |
| } else { |
| if (idCounts.get(deviceId) != 1) { |
| testFailed(`: device ID in ${frameInfos[i].origin} is not unique`); |
| success = false; |
| } |
| } |
| } |
| |
| debug(''); |
| if (success) |
| testPassed(`: device IDs in http://localhost:8000 persist, all others are unique`); |
| |
| debug(''); |
| finishJSTest(); |
| } |
| |
| addEventListener("message", handler, false); |
| |
| </script> |
| </head> |
| <body onload="setup()"> |
| <iframe src="http://localhost:8000/media/media-stream/resources/enumerate-devices-source-id-frame.html"></iframe> |
| <br> |
| <iframe src="http://127.0.0.1:8000/media/media-stream/resources/enumerate-devices-source-id-frame.html"></iframe> |
| <br> |
| <iframe src="http://localhost:8000/media/media-stream/resources/enumerate-devices-source-id-frame.html"></iframe> |
| <div id="console"></div> |
| <script src="../../../../resources/js-test-post.js"></script> |
| </body> |
| </html> |