OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 var tabCapture = chrome.tabCapture; |
| 6 |
| 7 var helloWorldPageUri = 'data:text/html;charset=UTF-8,' + |
| 8 encodeURIComponent('<html><body>Hello world!</body></html>'); |
| 9 |
| 10 chrome.test.runTests([ |
| 11 function canOpenUpToThreeOffscreenTabs() { |
| 12 function stopAllStreams(streams) { |
| 13 for (var i = 0, end = streams.length; i < end; ++i) { |
| 14 streams[i].getVideoTracks()[0].stop(); |
| 15 } |
| 16 } |
| 17 |
| 18 function launchTabsUntilLimitReached(streamsSoFar) { |
| 19 tabCapture.captureOffscreenTab( |
| 20 helloWorldPageUri, |
| 21 {video: true}, |
| 22 function(stream) { |
| 23 if (streamsSoFar.length == 3) { |
| 24 // 4th off-screen tab capture should fail. |
| 25 chrome.test.assertFalse(!!stream); |
| 26 stopAllStreams(streamsSoFar); |
| 27 chrome.test.succeed(); |
| 28 } else if (stream) { |
| 29 streamsSoFar.push(stream); |
| 30 setTimeout( |
| 31 function() { |
| 32 launchTabsUntilLimitReached(streamsSoFar); |
| 33 }, 0); |
| 34 } else { |
| 35 console.error("Failed to capture stream, iter #" + |
| 36 streamsSoFar.length); |
| 37 stopAllStreams(streamsSoFar); |
| 38 chrome.test.fail(); |
| 39 } |
| 40 }); |
| 41 } |
| 42 |
| 43 launchTabsUntilLimitReached([]); |
| 44 } |
| 45 ]); |
OLD | NEW |