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

Unified Diff: chrome/test/data/extensions/api_test/offscreen_tabs/crud.js

Issue 9234042: Re-land alexbost's experimental offscreenTabs API. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 9 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/offscreen_tabs/crud.js
diff --git a/chrome/test/data/extensions/api_test/offscreen_tabs/crud.js b/chrome/test/data/extensions/api_test/offscreen_tabs/crud.js
new file mode 100644
index 0000000000000000000000000000000000000000..e33f3bccf2bdcafaf5851151b4f56a0c06708a6b
--- /dev/null
+++ b/chrome/test/data/extensions/api_test/offscreen_tabs/crud.js
@@ -0,0 +1,66 @@
+// Copyright (c) 2012 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 tabList = [
+ { url: 'a.html', width: 200, height: 200 },
+ { url: 'b.html', width: 200, height: 200 },
+ { url: 'c.html', width: 1000,height: 800 }
+];
+
+// Holds the tab objects once they're created.
+var tabs = [];
+
+chrome.test.runTests([
+ function create() {
+ tabList.forEach(function(tab) {
+ chrome.experimental.offscreenTabs.create(
+ tab, pass(function(offscreenTab) {
+ tabs.push(offscreenTab);
+ assertSimilarTabs(tab, offscreenTab);
+ }));
+ });
+ },
+
+ function getAll() {
+ chrome.experimental.offscreenTabs.getAll(pass(function(offscreenTabs) {
+ var tabSorter = function(tab1, tab2) { return tab1.id - tab2.id; };
+ offscreenTabs.sort(tabSorter);
+ tabs.sort(tabSorter);
+ assertEq(tabs.length, offscreenTabs.length);
+ assertEq(tabs.length, tabList.length);
+ for (var i = 0; i < tabs.length; i++)
+ assertEqTabs(tabs[i], offscreenTabs[i]);
+ }));
+ },
+
+ function get() {
+ chrome.experimental.offscreenTabs.get(tabs[0].id, pass(function(tab) {
+ assertEqTabs(tabs[0], tab);
+ }));
+ },
+
+ function update() {
+ chrome.test.listenOnce(
+ chrome.experimental.offscreenTabs.onUpdated,
+ function(tabId, changeInfo, tab) {
+ assertSimilarTabs(tabList[0], tab);
+ });
+
+ // Update the 2nd tab to be like the 1st one.
+ chrome.experimental.offscreenTabs.update(
+ tabs[1].id, tabList[0], pass(function() {
+ chrome.experimental.offscreenTabs.get(tabs[1].id, pass(function(tab) {
+ assertSimilarTabs(tabList[0], tab);
+ }));
+ }));
+ },
+
+ function remove() {
+ tabs.forEach(function(tab) {
+ chrome.experimental.offscreenTabs.remove(tab.id, pass(function() {
+ assertTabDoesNotExist(tab.id);
+ }));
+ });
+ }
+]);

Powered by Google App Engine
This is Rietveld 408576698