Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3945)

Unified Diff: chrome/test/data/extensions/api_test/tabs/basics/autoDiscardable.js

Issue 2205523002: AutoDiscardable property support on Chrome Extensions Tabs API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nits fixed Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..8fa9c1b2e036593c9d1550a73acf3d1205892474
--- /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() {
Devlin 2016/08/02 22:48:14 Can we combine this with the other discardable tes
Anderson Silva 2016/08/03 14:47:41 You mean do set and reset (both update() calls) in
Devlin 2016/08/10 19:25:12 I meant adding this to chrome/test/data/extensions
Anderson Silva 2016/08/10 20:30:53 Hmm, I think it would work as well doing it altoge
Devlin 2016/08/10 20:45:49 Extension javascript tests are designed to be able
Devlin 2016/08/10 20:48:01 (here's an example: https://cs.chromium.org/chromi
Anderson Silva 2016/08/10 20:49:58 Oh, I see you mean now. It's basically using the s
+ // 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() {
+ // 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);
+ }));
+ }
+]);

Powered by Google App Engine
This is Rietveld 408576698