Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. | |
|
Devlin
2016/07/29 16:01:09
ditto
Anderson Silva
2016/07/29 19:05:59
Done.
| |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 var testTab; | |
| 6 chrome.test.runTests([ | |
| 7 | |
| 8 function setupWindow() { | |
| 9 var testTabId; | |
| 10 | |
| 11 createWindow(["about:blank", "chrome://newtab/"], {}, | |
| 12 pass(function (winId, tabIds) { | |
| 13 testTabId = tabIds[1]; | |
| 14 })); | |
| 15 | |
| 16 waitForAllTabs(pass(function () { | |
| 17 queryForTab(testTabId, {}, pass(function (tab) { | |
| 18 testTab = tab; | |
| 19 })); | |
| 20 })); | |
| 21 }, | |
| 22 | |
| 23 function discard() { | |
| 24 // Initially tab isn't discarded. | |
| 25 assertFalse(testTab.discarded); | |
| 26 | |
| 27 var onUpdatedCompleted = chrome.test.listenForever( | |
| 28 chrome.tabs.onUpdated, | |
| 29 function (tabId, changeInfo, tab) { | |
| 30 if ('discarded' in changeInfo) { | |
| 31 // Make sure it's the right tab. | |
| 32 assertEq(testTab.index, tab.index); | |
| 33 assertEq(testTab.windowId, tab.windowId); | |
| 34 | |
| 35 // Make sure the discarded state changed correctly. | |
| 36 assertTrue(changeInfo.discarded); | |
| 37 assertTrue(tab.discarded); | |
| 38 | |
| 39 onUpdatedCompleted(); | |
| 40 } | |
| 41 } | |
| 42 ); | |
| 43 | |
| 44 // Discard and update testTab (the id changes after a tab is discarded). | |
|
Devlin
2016/07/29 16:01:09
The id changes? That's a bit yucky. We normally
Anderson Silva
2016/07/29 19:05:59
Yeah, you're right, this is weird. But it isn't re
Devlin
2016/07/29 20:17:33
Cool, thanks! I don't want to block this issue on
| |
| 45 chrome.tabs.discard(testTab.id, pass(function (tab) { | |
| 46 assertTrue(tab.discarded); | |
| 47 testTab = tab; | |
| 48 })); | |
| 49 }, | |
| 50 | |
| 51 function reload() { | |
| 52 // Tab is already discarded. | |
| 53 assertTrue(testTab.discarded); | |
| 54 | |
| 55 var onUpdatedCompleted = chrome.test.listenForever( | |
| 56 chrome.tabs.onUpdated, | |
| 57 function (tabId, changeInfo, tab) { | |
| 58 if ('discarded' in changeInfo) { | |
| 59 // Make sure it's the right tab. | |
| 60 assertEq(testTab.index, tab.index); | |
| 61 assertEq(testTab.windowId, tab.windowId); | |
| 62 | |
| 63 // Make sure the discarded state changed correctly. | |
| 64 assertFalse(changeInfo.discarded); | |
| 65 assertFalse(tab.discarded); | |
| 66 | |
| 67 onUpdatedCompleted(); | |
| 68 } | |
| 69 } | |
| 70 ); | |
| 71 | |
| 72 chrome.tabs.reload(testTab.id); | |
| 73 } | |
| 74 ]); | |
| OLD | NEW |