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

Side by Side Diff: chrome/test/data/extensions/api_test/tab_capture/api_tests.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
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 var tabCapture = chrome.tabCapture; 5 var tabCapture = chrome.tabCapture;
6 6
7 var helloWorldPageUri = 'data:text/html;charset=UTF-8,' +
8 encodeURIComponent('<html><body>Hello world!</body></html>');
9
10 function assertIsSameSetOfTabs(list_a, list_b, id_field_name) {
11 chrome.test.assertEq(list_a.length, list_b.length);
12 function tabIdSortFunction(a, b) {
13 return (a[id_field_name] || 0) - (b[id_field_name] || 0);
14 }
15 list_a.sort(tabIdSortFunction);
16 list_b.sort(tabIdSortFunction);
17 for (var i = 0, end = list_a.length; i < end; ++i) {
18 chrome.test.assertEq(list_a[i][id_field_name], list_b[i][id_field_name]);
19 }
20 }
21
7 chrome.test.runTests([ 22 chrome.test.runTests([
8 function captureTabAndVerifyStateTransitions() { 23 function captureTabAndVerifyStateTransitions() {
9 // Tab capture events in the order they happen. 24 // Tab capture events in the order they happen.
10 var tabCaptureEvents = []; 25 var tabCaptureEvents = [];
11 26
12 var tabCaptureListener = function(info) { 27 var tabCaptureListener = function(info) {
13 console.log(info.status); 28 console.log(info.status);
14 if (info.status == 'stopped') { 29 if (info.status == 'stopped') {
15 chrome.test.assertEq('active', tabCaptureEvents.pop()); 30 chrome.test.assertEq('active', tabCaptureEvents.pop());
16 chrome.test.assertEq('pending', tabCaptureEvents.pop()); 31 chrome.test.assertEq('pending', tabCaptureEvents.pop());
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 chrome.test.succeed(); 152 chrome.test.succeed();
138 }); 153 });
139 }, 154 },
140 155
141 function noAudioOrVideoRequested() { 156 function noAudioOrVideoRequested() {
142 // If not specified, video is not requested. 157 // If not specified, video is not requested.
143 tabCapture.capture({audio: false}, function(stream) { 158 tabCapture.capture({audio: false}, function(stream) {
144 chrome.test.assertTrue(!stream); 159 chrome.test.assertTrue(!stream);
145 chrome.test.succeed(); 160 chrome.test.succeed();
146 }); 161 });
162 },
163
164 function offscreenTabsDoNotShowUpAsCapturedTabs() {
165 tabCapture.getCapturedTabs(function(tab_list_before) {
166 tabCapture.captureOffscreenTab(
167 helloWorldPageUri,
168 {video: true},
169 function(stream) {
170 chrome.test.assertTrue(!!stream);
171 tabCapture.getCapturedTabs(function(tab_list_after) {
172 assertIsSameSetOfTabs(tab_list_before, tab_list_after, 'tabId');
173 stream.getVideoTracks()[0].stop();
174 chrome.test.succeed();
175 });
176 });
177 });
178 },
179
180 function offscreenTabsDoNotShowUpInTabsQuery() {
181 chrome.tabs.query({/* all tabs */}, function(tab_list_before) {
182 tabCapture.captureOffscreenTab(
183 helloWorldPageUri,
184 {video: true},
185 function(stream) {
186 chrome.test.assertTrue(!!stream);
187 chrome.tabs.query({/* all tabs */}, function(tab_list_after) {
188 assertIsSameSetOfTabs(tab_list_before, tab_list_after, 'id');
189 stream.getVideoTracks()[0].stop();
190 chrome.test.succeed();
191 });
192 });
193 });
147 } 194 }
148 ]); 195 ]);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698