blob: e3a752c9ff00e3e8f6c1adb4168ca06053e9ad72 [file] [log] [blame]
// Copyright 2018 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(), when current window is null
// browser_tests.exe --gtest_filter=ExtensionApiTest.CaptureNullWindow
chrome.test.runTests([function captureNullWindow() {
// Create a new window so we don't close the only active window.
chrome.windows.create(function(newWindow) {
chrome.windows.remove(newWindow.id, function() {
chrome.tabs.captureVisibleTab(
newWindow.id, function() {
// The error message is non-deterministic based on how far we've gone
// in removing the window.
const error1 = `No window with id: ${newWindow.id}.`;
const error2 = 'No active web contents to capture';
chrome.test.assertTrue(!!chrome.runtime.lastError);
let actualError = chrome.runtime.lastError.message;
chrome.test.assertTrue(actualError == error1 || actualError == error2,
actualError);
chrome.test.succeed();
});
});
});
}]);