Chromium Code Reviews| Index: chrome/test/data/extensions/api_test/tabs/basics/autoDiscardable.js |
| diff --git a/chrome/test/data/extensions/api_test/tabs/basics/autoDiscardable.js b/chrome/test/data/extensions/api_test/tabs/basics/autoDiscardable.js |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..900097b22cd75913ceeb1d6806ff547e000065fd |
| --- /dev/null |
| +++ b/chrome/test/data/extensions/api_test/tabs/basics/autoDiscardable.js |
| @@ -0,0 +1,73 @@ |
| +// Copyright 2016 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 testTab; |
| +chrome.test.runTests([ |
| + |
| + function setupWindow() { |
| + var testTabId; |
| + |
| + createWindow(["about:blank", "chrome://newtab/"], {}, |
| + pass(function(winId, tabIds) { |
| + testTabId = tabIds[1]; |
| + })); |
| + |
| + waitForAllTabs(pass(function() { |
| + queryForTab(testTabId, {}, pass(function(tab) { |
| + testTab = tab; |
| + })); |
| + })); |
| + }, |
| + |
| + function setNonAutoDiscardable() { |
| + // Initially the tab is auto-discardable. |
| + assertTrue(testTab.autoDiscardable); |
| + |
| + var onUpdatedCompleted = chrome.test.listenForever( |
| + chrome.tabs.onUpdated, |
| + function(tabId, changeInfo, tab) { |
| + if ('autoDiscardable' in changeInfo) { |
| + // Make sure it's the right tab. |
| + assertEq(testTab.id, tab.id); |
| + |
| + // Make sure the auto-discardable state changed correctly. |
| + assertFalse(changeInfo.autoDiscardable); |
| + assertFalse(tab.autoDiscardable); |
| + |
| + onUpdatedCompleted(); |
| + } |
| + }); |
| + |
| + chrome.tabs.update(testTab.id, { autoDiscardable: false }, |
| + pass(function (tab) { |
| + assertFalse(tab.autoDiscardable); |
| + testTab = tab; |
| + })); |
| + }, |
| + |
| + function resetAutoDiscardable() { |
|
chrisha
2016/08/02 14:40:06
Another +2 indent here as well?
Anderson Silva
2016/08/02 15:02:43
Done.
|
| + // Tab was set to non auto-discardable. |
| + assertFalse(testTab.autoDiscardable); |
| + |
| + var onUpdatedCompleted = chrome.test.listenForever( |
| + chrome.tabs.onUpdated, |
| + function(tabId, changeInfo, tab) { |
| + if ('autoDiscardable' in changeInfo) { |
| + // Make sure it's the right tab. |
| + assertEq(testTab.id, tab.id); |
| + |
| + // Make sure the auto-discardable state changed correctly. |
| + assertTrue(changeInfo.autoDiscardable); |
| + assertTrue(tab.autoDiscardable); |
| + |
| + onUpdatedCompleted(); |
| + } |
| + }); |
| + |
| + chrome.tabs.update(testTab.id, { autoDiscardable: true }, |
| + pass(function (tab) { |
| + assertTrue(tab.autoDiscardable); |
| + })); |
| + } |
| +]); |