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

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: 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/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..c55e8f60cc3875999a9392c50e58d97be49de27a 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
@@ -4,6 +4,21 @@
var tabCapture = chrome.tabCapture;
+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() {
// Tab capture events in the order they happen.
@@ -144,5 +159,37 @@ 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();
+ });
+ });
+ });
}
]);

Powered by Google App Engine
This is Rietveld 408576698