blob: 4d392a2c090d2f11e2dfbc33ab88d642ee8ca5ab [file] [log] [blame]
// Copyright (c) 2012 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.
// API test for chrome.tabs.captureVisibleTab(), screenshot disabling policy.
// browser_tests.exe --gtest_filter=ExtensionApiTest.CaptureVisibleDisabled
var pass = chrome.test.callbackPass;
var fail = chrome.test.callbackFail;
var assertEq = chrome.test.assertEq;
var assertTrue = chrome.test.assertTrue;
var assertFalse = chrome.test.assertFalse;
var kWindowRect = {
'width': 400,
'height': 400
};
chrome.test.getConfig((config) => {
const kError = 'Taking screenshots has been disabled';
const kUrl = `localhost:${config.testServer.port}/simple.html`;
chrome.test.runTests([
function captureVisibleDisabled() {
createWindow([kUrl], kWindowRect, pass(function(winId, tabIds) {
waitForAllTabs(pass(function() {
chrome.tabs.getSelected(winId, pass(function(tab) {
assertEq('complete', tab.status);
chrome.tabs.captureVisibleTab(winId, fail(kError));
}));
}));
}));
},
function captureVisibleDisabledInNullWindow() {
chrome.tabs.create({url: kUrl}, pass(() => {
waitForAllTabs(pass(() => {
chrome.tabs.captureVisibleTab(null, fail(kError));
}));
}));
},
function captureVisibleDisabledInCurrentWindow() {
chrome.tabs.captureVisibleTab(chrome.windows.WINDOW_ID_CURRENT,
fail(kError));
}
]);
});