Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
| 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 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
| |
| 24 // Initially the tab is auto-discardable. | |
| 25 assertTrue(testTab.autoDiscardable); | |
| 26 | |
| 27 var onUpdatedCompleted = chrome.test.listenForever( | |
| 28 chrome.tabs.onUpdated, | |
| 29 function(tabId, changeInfo, tab) { | |
| 30 if ('autoDiscardable' in changeInfo) { | |
| 31 // Make sure it's the right tab. | |
| 32 assertEq(testTab.id, tab.id); | |
| 33 | |
| 34 // Make sure the auto-discardable state changed correctly. | |
| 35 assertFalse(changeInfo.autoDiscardable); | |
| 36 assertFalse(tab.autoDiscardable); | |
| 37 | |
| 38 onUpdatedCompleted(); | |
| 39 } | |
| 40 }); | |
| 41 | |
| 42 chrome.tabs.update(testTab.id, { autoDiscardable: false }, | |
| 43 pass(function (tab) { | |
| 44 assertFalse(tab.autoDiscardable); | |
| 45 testTab = tab; | |
| 46 })); | |
| 47 }, | |
| 48 | |
| 49 function resetAutoDiscardable() { | |
| 50 // Tab was set to non auto-discardable. | |
| 51 assertFalse(testTab.autoDiscardable); | |
| 52 | |
| 53 var onUpdatedCompleted = chrome.test.listenForever( | |
| 54 chrome.tabs.onUpdated, | |
| 55 function(tabId, changeInfo, tab) { | |
| 56 if ('autoDiscardable' in changeInfo) { | |
| 57 // Make sure it's the right tab. | |
| 58 assertEq(testTab.id, tab.id); | |
| 59 | |
| 60 // Make sure the auto-discardable state changed correctly. | |
| 61 assertTrue(changeInfo.autoDiscardable); | |
| 62 assertTrue(tab.autoDiscardable); | |
| 63 | |
| 64 onUpdatedCompleted(); | |
| 65 } | |
| 66 }); | |
| 67 | |
| 68 chrome.tabs.update(testTab.id, { autoDiscardable: true }, | |
| 69 pass(function (tab) { | |
| 70 assertTrue(tab.autoDiscardable); | |
| 71 })); | |
| 72 } | |
| 73 ]); | |
| OLD | NEW |