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

Side by Side Diff: chrome/test/data/extensions/api_test/tab_capture/experimental/test.js

Issue 11198044: Make tab capture media stream requests verify that the request came from extension API (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review comments Created 8 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 chrome.test.runTests([ 7 chrome.test.runTests([
8 8
9 function captureInvalidTab() { 9 function captureInvalidTab() {
10 var tabMediaRequestCallback = function(stream) { 10 var tabMediaRequestCallback = function(stream) {
(...skipping 16 matching lines...) Expand all
27 stream.stop(); 27 stream.stop();
28 }; 28 };
29 29
30 var tabCaptureListener = function(info) { 30 var tabCaptureListener = function(info) {
31 chrome.test.assertEq(tabId, info.tabId); 31 chrome.test.assertEq(tabId, info.tabId);
32 console.log(info.status); 32 console.log(info.status);
33 if (info.status == 'stopped') { 33 if (info.status == 'stopped') {
34 chrome.test.assertEq('active', tabCaptureEvents.pop()); 34 chrome.test.assertEq('active', tabCaptureEvents.pop());
35 chrome.test.assertEq('pending', tabCaptureEvents.pop()); 35 chrome.test.assertEq('pending', tabCaptureEvents.pop());
36 chrome.test.assertEq('requested', tabCaptureEvents.pop()); 36 chrome.test.assertEq('requested', tabCaptureEvents.pop());
37 tabCapture.onStatusChanged.removeListener(tabCaptureListener);
37 chrome.test.succeed(); 38 chrome.test.succeed();
38 return; 39 return;
39 } 40 }
40 tabCaptureEvents.push(info.status); 41 tabCaptureEvents.push(info.status);
41 } 42 }
42 43
43 tabCapture.onStatusChanged.addListener(tabCaptureListener); 44 tabCapture.onStatusChanged.addListener(tabCaptureListener);
44 45
45 var gotTabId = function(tab) { 46 var gotTabId = function(tab) {
46 tabId = tab[0].id; 47 tabId = tab[0].id;
(...skipping 13 matching lines...) Expand all
60 chrome.test.assertEq(tabId, infos[0].tabId); 61 chrome.test.assertEq(tabId, infos[0].tabId);
61 chrome.test.assertEq('stopped', infos[0].status); 62 chrome.test.assertEq('stopped', infos[0].status);
62 chrome.test.succeed(); 63 chrome.test.succeed();
63 } 64 }
64 65
65 var capturedTabsAfterOpen = function(infos) { 66 var capturedTabsAfterOpen = function(infos) {
66 chrome.test.assertEq(1, infos.length); 67 chrome.test.assertEq(1, infos.length);
67 chrome.test.assertEq(tabId, infos[0].tabId); 68 chrome.test.assertEq(tabId, infos[0].tabId);
68 chrome.test.assertEq('active', infos[0].status); 69 chrome.test.assertEq('active', infos[0].status);
69 activeStream.stop(); 70 activeStream.stop();
71 tabCapture.getCapturedTabs(capturedTabsAfterClose);
70 } 72 }
71 73
72 var tabMediaRequestCallback = function(stream) { 74 var tabMediaRequestCallback = function(stream) {
73 chrome.test.assertTrue(stream !== undefined); 75 chrome.test.assertTrue(stream !== undefined);
74 activeStream = stream; 76 activeStream = stream;
75 tabCapture.getCapturedTabs(capturedTabsAfterOpen); 77 tabCapture.getCapturedTabs(capturedTabsAfterOpen);
76 }; 78 };
77 79
78 var gotTabId = function(tab) { 80 var gotTabId = function(tab) {
79 tabId = tab[0].id; 81 tabId = tab[0].id;
(...skipping 26 matching lines...) Expand all
106 var gotTabId = function(tab) { 108 var gotTabId = function(tab) {
107 tabId = tab[0].id; 109 tabId = tab[0].id;
108 console.log('using tab: ' + tabId); 110 console.log('using tab: ' + tabId);
109 tabCapture.capture(tabId, {audio: true, video: true}, 111 tabCapture.capture(tabId, {audio: true, video: true},
110 tabMediaRequestCallback); 112 tabMediaRequestCallback);
111 }; 113 };
112 chrome.tabs.query({active: true}, gotTabId); 114 chrome.tabs.query({active: true}, gotTabId);
113 }, 115 },
114 116
115 ]); 117 ]);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698