| OLD | NEW |
| (Empty) | |
| 1 // Copyright (c) 2012 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 tabList = [ |
| 6 { url: 'a.html', width: 200, height: 200 }, |
| 7 { url: 'b.html', width: 200, height: 200 }, |
| 8 { url: 'c.html', width: 1000,height: 800 } |
| 9 ]; |
| 10 |
| 11 // Holds the tab objects once they're created. |
| 12 var tabs = []; |
| 13 |
| 14 chrome.test.runTests([ |
| 15 function create() { |
| 16 tabList.forEach(function(tab) { |
| 17 chrome.experimental.offscreenTabs.create( |
| 18 tab, pass(function(offscreenTab) { |
| 19 tabs.push(offscreenTab); |
| 20 assertSimilarTabs(tab, offscreenTab); |
| 21 })); |
| 22 }); |
| 23 }, |
| 24 |
| 25 function getAll() { |
| 26 chrome.experimental.offscreenTabs.getAll(pass(function(offscreenTabs) { |
| 27 var tabSorter = function(tab1, tab2) { return tab1.id - tab2.id; }; |
| 28 offscreenTabs.sort(tabSorter); |
| 29 tabs.sort(tabSorter); |
| 30 assertEq(tabs.length, offscreenTabs.length); |
| 31 assertEq(tabs.length, tabList.length); |
| 32 for (var i = 0; i < tabs.length; i++) |
| 33 assertEqTabs(tabs[i], offscreenTabs[i]); |
| 34 })); |
| 35 }, |
| 36 |
| 37 function get() { |
| 38 chrome.experimental.offscreenTabs.get(tabs[0].id, pass(function(tab) { |
| 39 assertEqTabs(tabs[0], tab); |
| 40 })); |
| 41 }, |
| 42 |
| 43 function update() { |
| 44 chrome.test.listenOnce( |
| 45 chrome.experimental.offscreenTabs.onUpdated, |
| 46 function(tabId, changeInfo, tab) { |
| 47 assertSimilarTabs(tabList[0], tab); |
| 48 }); |
| 49 |
| 50 // Update the 2nd tab to be like the 1st one. |
| 51 chrome.experimental.offscreenTabs.update( |
| 52 tabs[1].id, tabList[0], pass(function() { |
| 53 chrome.experimental.offscreenTabs.get(tabs[1].id, pass(function(tab) { |
| 54 assertSimilarTabs(tabList[0], tab); |
| 55 })); |
| 56 })); |
| 57 }, |
| 58 |
| 59 function remove() { |
| 60 tabs.forEach(function(tab) { |
| 61 chrome.experimental.offscreenTabs.remove(tab.id, pass(function() { |
| 62 assertTabDoesNotExist(tab.id); |
| 63 })); |
| 64 }); |
| 65 } |
| 66 ]); |
| OLD | NEW |