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

Unified 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 side-by-side diff with in-line comments
Download patch
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([]);
+ }
+]);

Powered by Google App Engine
This is Rietveld 408576698