| Index: chrome/test/data/extensions/api_test/tab_capture/max_offscreen_tabs.js
|
| diff --git a/chrome/test/data/extensions/api_test/tab_capture/max_offscreen_tabs.js b/chrome/test/data/extensions/api_test/tab_capture/max_offscreen_tabs.js
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..89b8c4df94318df5346aa7eed34a266644e5c787
|
| --- /dev/null
|
| +++ b/chrome/test/data/extensions/api_test/tab_capture/max_offscreen_tabs.js
|
| @@ -0,0 +1,45 @@
|
| +// Copyright 2015 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +var tabCapture = chrome.tabCapture;
|
| +
|
| +var helloWorldPageUri = 'data:text/html;charset=UTF-8,' +
|
| + encodeURIComponent('<html><body>Hello world!</body></html>');
|
| +
|
| +chrome.test.runTests([
|
| + function canOpenUpToThreeOffscreenTabs() {
|
| + function stopAllStreams(streams) {
|
| + for (var i = 0, end = streams.length; i < end; ++i) {
|
| + streams[i].getVideoTracks()[0].stop();
|
| + }
|
| + }
|
| +
|
| + function launchTabsUntilLimitReached(streamsSoFar) {
|
| + tabCapture.captureOffscreenTab(
|
| + helloWorldPageUri,
|
| + {video: true},
|
| + function(stream) {
|
| + if (streamsSoFar.length == 3) {
|
| + // 4th off-screen tab capture should fail.
|
| + chrome.test.assertFalse(!!stream);
|
| + stopAllStreams(streamsSoFar);
|
| + chrome.test.succeed();
|
| + } else if (stream) {
|
| + streamsSoFar.push(stream);
|
| + setTimeout(
|
| + function() {
|
| + launchTabsUntilLimitReached(streamsSoFar);
|
| + }, 0);
|
| + } else {
|
| + console.error("Failed to capture stream, iter #" +
|
| + streamsSoFar.length);
|
| + stopAllStreams(streamsSoFar);
|
| + chrome.test.fail();
|
| + }
|
| + });
|
| + }
|
| +
|
| + launchTabsUntilLimitReached([]);
|
| + }
|
| +]);
|
|
|