| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 // API test for chrome.tabs.captureVisibleTab(), capturing JPEG images. | |
| 6 // browser_tests.exe --gtest_filter=ExtensionApiTest.CaptureVisibleNoFile | |
| 7 | |
| 8 var pass = chrome.test.callbackPass; | |
| 9 var fail = chrome.test.callbackFail; | |
| 10 var assertEq = chrome.test.assertEq; | |
| 11 var assertTrue = chrome.test.assertTrue; | |
| 12 var assertFalse = chrome.test.assertFalse; | |
| 13 | |
| 14 var kWindowRect = { | |
| 15 'width': 400, | |
| 16 'height': 400 | |
| 17 }; | |
| 18 | |
| 19 var fail_url = "file:///nosuch.html"; | |
| 20 | |
| 21 chrome.test.runTests([ | |
| 22 // Check that test infrastructure launched us without permissions. | |
| 23 function checkAllowedNoAccess() { | |
| 24 chrome.extension.isAllowedFileSchemeAccess(pass(function(hasAccess) { | |
| 25 assertFalse(hasAccess); | |
| 26 })); | |
| 27 }, | |
| 28 | |
| 29 // Check for no permssions error. | |
| 30 function captureVisibleNoFile() { | |
| 31 createWindow([fail_url], kWindowRect, pass(function(winId, tabIds) { | |
| 32 waitForAllTabs(pass(function() { | |
| 33 chrome.tabs.getSelected(winId, pass(function(tab) { | |
| 34 assertEq('complete', tab.status); | |
| 35 chrome.tabs.captureVisibleTab(winId, fail( | |
| 36 'Cannot access contents of url "' + fail_url + | |
| 37 '". Extension manifest must request permission ' + | |
| 38 'to access this host.')); | |
| 39 })); | |
| 40 })); | |
| 41 })); | |
| 42 } | |
| 43 | |
| 44 ]); | |
| OLD | NEW |