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

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

Issue 2142413003: Adding Discarded property support for onUpdate function. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@API_Discarded
Patch Set: todo Created 4 years, 5 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
« no previous file with comments | « chrome/test/data/extensions/api_test/tabs/basics/discarded.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/data/extensions/api_test/tabs/basics/discarded.js
diff --git a/chrome/test/data/extensions/api_test/tabs/basics/discarded.js b/chrome/test/data/extensions/api_test/tabs/basics/discarded.js
new file mode 100644
index 0000000000000000000000000000000000000000..bd485d4ac0730b669b77be00fff67836245a65e4
--- /dev/null
+++ b/chrome/test/data/extensions/api_test/tabs/basics/discarded.js
@@ -0,0 +1,76 @@
+// 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) {
Devlin 2016/07/29 21:23:40 indent parameters more, function body less: create
Anderson Silva 2016/07/29 22:12:24 Done.
+ testTabId = tabIds[1];
+ }));
+
+ waitForAllTabs(pass(function () {
Devlin 2016/07/29 21:23:40 no space between function and (
Anderson Silva 2016/07/29 22:12:24 Done.
+ queryForTab(testTabId, {}, pass(function (tab) {
+ testTab = tab;
+ }));
+ }));
+ },
+
+ function discard() {
+ // Initially tab isn't discarded.
+ assertFalse(testTab.discarded);
+
+ var onUpdatedCompleted = chrome.test.listenForever(
+ chrome.tabs.onUpdated,
+ function (tabId, changeInfo, tab) {
Devlin 2016/07/29 21:23:40 indent these two more, outdent the function body t
Anderson Silva 2016/07/29 22:12:24 Done.
+ if ('discarded' in changeInfo) {
+ // Make sure it's the right tab.
+ assertEq(testTab.index, tab.index);
+ assertEq(testTab.windowId, tab.windowId);
+
+ // Make sure the discarded state changed correctly.
+ assertTrue(changeInfo.discarded);
+ assertTrue(tab.discarded);
+
+ onUpdatedCompleted();
+ }
+ }
+ );
Devlin 2016/07/29 21:23:40 nit: put the paren and the closing function brace
Anderson Silva 2016/07/29 22:12:24 Done.
+
+ // TODO(georgesak): Remove tab update when http://crbug.com/632839 is
+ // resolved.
+ // Discard and update testTab (the id changes after a tab is discarded).
+ chrome.tabs.discard(testTab.id, pass(function (tab) {
+ assertTrue(tab.discarded);
+ testTab = tab;
+ }));
+ },
+
+ function reload() {
+ // Tab is already discarded.
+ assertTrue(testTab.discarded);
+
+ var onUpdatedCompleted = chrome.test.listenForever(
+ chrome.tabs.onUpdated,
Devlin 2016/07/29 21:23:40 see indentation advice for line 27
Anderson Silva 2016/07/29 22:12:24 Done.
+ function (tabId, changeInfo, tab) {
+ if ('discarded' in changeInfo) {
+ // Make sure it's the right tab.
+ assertEq(testTab.index, tab.index);
+ assertEq(testTab.windowId, tab.windowId);
+
+ // Make sure the discarded state changed correctly.
+ assertFalse(changeInfo.discarded);
+ assertFalse(tab.discarded);
+
+ onUpdatedCompleted();
+ }
+ }
+ );
+
+ chrome.tabs.reload(testTab.id);
+ }
+]);
« no previous file with comments | « chrome/test/data/extensions/api_test/tabs/basics/discarded.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698