Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1961)

Side by Side Diff: chrome/test/data/extensions/api_test/tab_capture/max_offscreen_tabs.js

Issue 1221483002: New tabCapture.captureOffscreenTab API, initially for Presentation API 1UA mode (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Mostly revert to Patch Set 6, plus minor tweaks. [and REBASE] Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 ]);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698