Chromium Code Reviews| Index: chrome/test/data/extensions/api_test/tab_capture/max_offscreen_tabs.js |
| diff --git a/chrome/test/data/extensions/api_test/tab_capture/max_offscreen_tabs.js b/chrome/test/data/extensions/api_test/tab_capture/max_offscreen_tabs.js |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..86a035f175ae69e5a6cd3ca3e60cccc961b361fe |
| --- /dev/null |
| +++ b/chrome/test/data/extensions/api_test/tab_capture/max_offscreen_tabs.js |
| @@ -0,0 +1,52 @@ |
| +// Copyright 2015 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +var tabCapture = chrome.tabCapture; |
| + |
| +var helloWorldPageUri = 'data:text/html;charset=UTF-8,' + |
| + encodeURIComponent('<html><body>Hello world!</body></html>'); |
| + |
| +chrome.test.runTests([ |
| + function canOpenUpToThreeOffscreenTabs() { |
| + tabCapture.captureOffscreenTab( |
| + helloWorldPageUri, |
| + {video: true}, |
| + function(stream1) { |
| + // 1st off-screen tab capture should succeed. |
| + chrome.test.assertTrue(!!stream1); |
| + if (!stream1) return; |
| + |
| + tabCapture.captureOffscreenTab( |
| + helloWorldPageUri, |
| + {video: true}, |
| + function(stream2) { |
| + // 2nd off-screen tab capture should succeed. |
| + chrome.test.assertTrue(!!stream2); |
| + if (!stream2) return; |
|
imcheng
2015/09/29 01:28:56
You'd have to stop stream1 before returning, right
miu
2015/09/30 19:46:38
Not really, but that *would* be cleaner.
I rewrot
|
| + |
| + tabCapture.captureOffscreenTab( |
| + helloWorldPageUri, |
| + {video: true}, |
| + function(stream3) { |
| + // 3rd off-screen tab capture should succeed. |
| + chrome.test.assertTrue(!!stream3); |
| + if (!stream3) return; |
| + |
| + tabCapture.captureOffscreenTab( |
| + helloWorldPageUri, |
| + {video: true}, |
| + function(stream4) { |
| + // 4th off-screen tab capture should fail. |
| + chrome.test.assertFalse(!!stream4); |
| + |
| + stream3.getVideoTracks()[0].stop(); |
| + stream2.getVideoTracks()[0].stop(); |
| + stream1.getVideoTracks()[0].stop(); |
| + chrome.test.succeed(); |
| + }); |
| + }); |
| + }); |
| + }); |
| + } |
| +]); |