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

Unified 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: Register off-screen tabs as presentations via separate private API. Created 5 years, 3 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/api_tests.js
diff --git a/chrome/test/data/extensions/api_test/tab_capture/api_tests.js b/chrome/test/data/extensions/api_test/tab_capture/api_tests.js
index 1efad1de61f8b4b295784fc716fc78dd0ef11a35..9ba626c80dd3cff366bd89dc4470b370a321a493 100644
--- a/chrome/test/data/extensions/api_test/tab_capture/api_tests.js
+++ b/chrome/test/data/extensions/api_test/tab_capture/api_tests.js
@@ -3,6 +3,22 @@
// found in the LICENSE file.
var tabCapture = chrome.tabCapture;
+var tabCapturePrivate = chrome.tabCapturePrivate;
+
+var helloWorldPageUri = 'data:text/html;charset=UTF-8,' +
+ encodeURIComponent('<html><body>Hello world!</body></html>');
+
+function assertIsSameSetOfTabs(list_a, list_b, id_field_name) {
+ chrome.test.assertEq(list_a.length, list_b.length);
+ function tabIdSortFunction(a, b) {
+ return (a[id_field_name] || 0) - (b[id_field_name] || 0);
+ }
+ list_a.sort(tabIdSortFunction);
+ list_b.sort(tabIdSortFunction);
+ for (var i = 0, end = list_a.length; i < end; ++i) {
+ chrome.test.assertEq(list_a[i][id_field_name], list_b[i][id_field_name]);
+ }
+}
chrome.test.runTests([
function captureTabAndVerifyStateTransitions() {
@@ -144,5 +160,63 @@ chrome.test.runTests([
chrome.test.assertTrue(!stream);
chrome.test.succeed();
});
+ },
+
+ function offscreenTabsDoNotShowUpAsCapturedTabs() {
+ tabCapture.getCapturedTabs(function(tab_list_before) {
+ tabCapture.captureOffscreenTab(
+ helloWorldPageUri,
+ {video: true},
+ function(stream) {
+ chrome.test.assertTrue(!!stream);
+ tabCapture.getCapturedTabs(function(tab_list_after) {
+ assertIsSameSetOfTabs(tab_list_before, tab_list_after, 'tabId');
+ stream.getVideoTracks()[0].stop();
+ chrome.test.succeed();
+ });
+ });
+ });
+ },
+
+ function offscreenTabsDoNotShowUpInTabsQuery() {
+ chrome.tabs.query({/* all tabs */}, function(tab_list_before) {
+ tabCapture.captureOffscreenTab(
+ helloWorldPageUri,
+ {video: true},
+ function(stream) {
+ chrome.test.assertTrue(!!stream);
+ chrome.tabs.query({/* all tabs */}, function(tab_list_after) {
+ assertIsSameSetOfTabs(tab_list_before, tab_list_after, 'id');
+ stream.getVideoTracks()[0].stop();
+ chrome.test.succeed();
+ });
+ });
+ });
+ },
+
+ function canRegisterOffscreenTabsAsPresentations() {
+ tabCapture.captureOffscreenTab(
+ helloWorldPageUri,
+ {video: true},
+ function(stream) {
+ chrome.test.assertTrue(!!stream);
+ chrome.test.assertTrue((stream['offscreenTabId'] || '').length > 0);
+ tabCapturePrivate.registerOffscreenTabAsPresentation(
+ stream['offscreenTabId'],
+ '<PRESENTATION ID>',
+ function() {
+ var error = chrome.runtime.lastError;
+ if (error) {
+ if (error.message) {
+ console.error(error.message);
+ }
+ chrome.test.fail();
+ } else {
+ chrome.test.succeed();
+ }
+ }
+ );
+ }
+ );
}
]);

Powered by Google App Engine
This is Rietveld 408576698