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

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: Created 5 years, 5 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
7 chrome.test.runTests([ 10 chrome.test.runTests([
8 function captureTabAndVerifyStateTransitions() { 11 function captureTabAndVerifyStateTransitions() {
9 // Tab capture events in the order they happen. 12 // Tab capture events in the order they happen.
10 var tabCaptureEvents = []; 13 var tabCaptureEvents = [];
11 14
12 var tabCaptureListener = function(info) { 15 var tabCaptureListener = function(info) {
13 console.log(info.status); 16 console.log(info.status);
14 if (info.status == 'stopped') { 17 if (info.status == 'stopped') {
15 chrome.test.assertEq('active', tabCaptureEvents.pop()); 18 chrome.test.assertEq('active', tabCaptureEvents.pop());
16 chrome.test.assertEq('pending', tabCaptureEvents.pop()); 19 chrome.test.assertEq('pending', tabCaptureEvents.pop());
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 chrome.test.succeed(); 115 chrome.test.succeed();
113 }); 116 });
114 }, 117 },
115 118
116 function noAudioOrVideoRequested() { 119 function noAudioOrVideoRequested() {
117 // If not specified, video is not requested. 120 // If not specified, video is not requested.
118 tabCapture.capture({audio: false}, function(stream) { 121 tabCapture.capture({audio: false}, function(stream) {
119 chrome.test.assertTrue(!stream); 122 chrome.test.assertTrue(!stream);
120 chrome.test.succeed(); 123 chrome.test.succeed();
121 }); 124 });
125 },
126
127 function offscreenTabsDoNotShowUpAsCapturedTabs() {
128 tabCapture.getCapturedTabs(function(captured_tabs_without_pres) {
129 tabCapture.capturePresentation(
130 helloWorldPageUri,
131 "puppies",
132 {video: true},
133 function(stream) {
134 chrome.test.assertTrue(!!stream);
135 tabCapture.getCapturedTabs(function(captured_tabs) {
136 // Confirm that the same set of tabs is present (no more, no
137 // less).
138 chrome.test.assertEq(captured_tabs_without_pres.length,
Kevin M 2015/06/29 22:17:02 Consider comparing the stringified arrays instead,
miu 2015/06/30 04:09:59 Done.
139 captured_tabs.length);
140 function tabIdSortFunction(a, b) {
141 return (a.tabId || 0) - (b.tabId || 0);
142 }
143 captured_tabs_without_pres.sort(tabIdSortFunction);
144 captured_tabs.sort(tabIdSortFunction);
145 for (var i = 0, end = captured_tabs.length; i < end; ++i) {
146 chrome.test.assertEq(captured_tabs_without_pres[i],
147 captured_tabs[i]);
148 }
149
150 stream.stop();
151 chrome.test.succeed();
152 });
153 });
154 });
155 },
156
157 function offscreenTabsDoNotShowUpInTabsQuery() {
158 chrome.tabs.query({/* all tabs */}, function(first_tab_list) {
159 tabCapture.capturePresentation(
160 helloWorldPageUri,
161 'kittens',
162 {video: true},
163 function(stream) {
164 chrome.test.assertTrue(!!stream);
165 chrome.tabs.query({/* all tabs */}, function(second_tab_list) {
166 // Confirm that the same set of tabs is present (no more, no
167 // less).
168 chrome.test.assertEq(first_tab_list.length,
169 second_tab_list.length);
170 function tabIdSortFunction(a, b) {
171 return (a.id || 0) - (b.id || 0);
172 }
173 first_tab_list.sort(tabIdSortFunction);
174 second_tab_list.sort(tabIdSortFunction);
175 for (var i = 0, end = first_tab_list.length; i < end; ++i) {
176 chrome.test.assertEq(first_tab_list[i], second_tab_list[i]);
177 }
178
179 stream.stop();
180 chrome.test.succeed();
181 });
182 });
183 });
122 } 184 }
123 ]); 185 ]);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698