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

Unified Diff: chrome/test/data/extensions/api_test/offscreen_tabs/display.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/display.js
diff --git a/chrome/test/data/extensions/api_test/offscreen_tabs/display.js b/chrome/test/data/extensions/api_test/offscreen_tabs/display.js
new file mode 100644
index 0000000000000000000000000000000000000000..1026b6ab8065fb8e3817a9ec716b1f41a0cde69d
--- /dev/null
+++ b/chrome/test/data/extensions/api_test/offscreen_tabs/display.js
@@ -0,0 +1,78 @@
+// 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 testTabs = [
+ { url: 'a.html', width: 200, height: 200 },
+ { url: 'b.html', width: 200, height: 200 }
+];
+
+var firstTabId;
+var secondTabId;
+var firstTabDataURL;
+var secondTabDataURL;
+
+var DATA_URL_PREFIX = 'data:image/png;base64,';
+
+chrome.test.runTests([
+ function createFirstTab() {
+ chrome.test.listenOnce(
+ chrome.experimental.offscreenTabs.onUpdated,
+ function(tabId, changeInfo, tab) {
+ assertSimilarTabs(testTabs[0], tab);
+ firstTabId = tab.id;
+ });
+
+ chrome.experimental.offscreenTabs.create(
+ testTabs[0], pass(function(tab) {
+ assertSimilarTabs(testTabs[0], tab);
+ }));
+ },
+
+ function createSecondTab() {
+ chrome.test.listenOnce(
+ chrome.experimental.offscreenTabs.onUpdated,
+ function(tabId, changeInfo, tab) {
+ assertSimilarTabs(testTabs[1], tab);
+ secondTabId = tab.id;
+ });
+
+ chrome.experimental.offscreenTabs.create(
+ testTabs[1], pass(function(tab) {
+ assertSimilarTabs(testTabs[1], tab);
+ }));
+ },
+
+ // Capture an image of the first tab and verify that the data URL looks
+ // reasonably correct.
+ function captureFirstTab() {
+ chrome.experimental.offscreenTabs.toDataUrl(
+ firstTabId, {format: 'png'}, pass(function(dataURL) {
+ assertEq('string', typeof(dataURL));
+ assertEq(DATA_URL_PREFIX, dataURL.substring(0, DATA_URL_PREFIX.length));
+ firstTabDataURL = dataURL;
+ }));
+ },
+
+ // Capture an image of the second tab and verify that the data URL looks
+ // reasonably correct.
+ function captureSecondTab() {
+ chrome.experimental.offscreenTabs.toDataUrl(
+ secondTabId, {format: 'png'}, pass(function(dataURL) {
+ assertEq('string', typeof(dataURL));
+ assertEq(DATA_URL_PREFIX, dataURL.substring(0, DATA_URL_PREFIX.length));
+ secondTabDataURL = dataURL;
+ }));
+ }
+
+ /*
+ This test does not work on Mac because the API always returns black images.
+
+ // Make sure the data URLs for the two tabs are different, since pages are
+ // different (though the height and widths are equal).
+ function compareCaptures() {
+ assertFalse(firstTabDataURL == secondTabDataURL);
+ chrome.test.succeed();
+ }
+ */
+]);

Powered by Google App Engine
This is Rietveld 408576698