| 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 testTabs = [ |
| 6 { url: 'a.html', width: 200, height: 200 }, |
| 7 { url: 'b.html', width: 200, height: 200 } |
| 8 ]; |
| 9 |
| 10 var firstTabId; |
| 11 var secondTabId; |
| 12 var firstTabDataURL; |
| 13 var secondTabDataURL; |
| 14 |
| 15 var DATA_URL_PREFIX = 'data:image/png;base64,'; |
| 16 |
| 17 chrome.test.runTests([ |
| 18 function createFirstTab() { |
| 19 chrome.test.listenOnce( |
| 20 chrome.experimental.offscreenTabs.onUpdated, |
| 21 function(tabId, changeInfo, tab) { |
| 22 assertSimilarTabs(testTabs[0], tab); |
| 23 firstTabId = tab.id; |
| 24 }); |
| 25 |
| 26 chrome.experimental.offscreenTabs.create( |
| 27 testTabs[0], pass(function(tab) { |
| 28 assertSimilarTabs(testTabs[0], tab); |
| 29 })); |
| 30 }, |
| 31 |
| 32 function createSecondTab() { |
| 33 chrome.test.listenOnce( |
| 34 chrome.experimental.offscreenTabs.onUpdated, |
| 35 function(tabId, changeInfo, tab) { |
| 36 assertSimilarTabs(testTabs[1], tab); |
| 37 secondTabId = tab.id; |
| 38 }); |
| 39 |
| 40 chrome.experimental.offscreenTabs.create( |
| 41 testTabs[1], pass(function(tab) { |
| 42 assertSimilarTabs(testTabs[1], tab); |
| 43 })); |
| 44 }, |
| 45 |
| 46 // Capture an image of the first tab and verify that the data URL looks |
| 47 // reasonably correct. |
| 48 function captureFirstTab() { |
| 49 chrome.experimental.offscreenTabs.toDataUrl( |
| 50 firstTabId, {format: 'png'}, pass(function(dataURL) { |
| 51 assertEq('string', typeof(dataURL)); |
| 52 assertEq(DATA_URL_PREFIX, dataURL.substring(0, DATA_URL_PREFIX.length)); |
| 53 firstTabDataURL = dataURL; |
| 54 })); |
| 55 }, |
| 56 |
| 57 // Capture an image of the second tab and verify that the data URL looks |
| 58 // reasonably correct. |
| 59 function captureSecondTab() { |
| 60 chrome.experimental.offscreenTabs.toDataUrl( |
| 61 secondTabId, {format: 'png'}, pass(function(dataURL) { |
| 62 assertEq('string', typeof(dataURL)); |
| 63 assertEq(DATA_URL_PREFIX, dataURL.substring(0, DATA_URL_PREFIX.length)); |
| 64 secondTabDataURL = dataURL; |
| 65 })); |
| 66 } |
| 67 |
| 68 /* |
| 69 This test does not work on Mac because the API always returns black images. |
| 70 |
| 71 // Make sure the data URLs for the two tabs are different, since pages are |
| 72 // different (though the height and widths are equal). |
| 73 function compareCaptures() { |
| 74 assertFalse(firstTabDataURL == secondTabDataURL); |
| 75 chrome.test.succeed(); |
| 76 } |
| 77 */ |
| 78 ]); |
| OLD | NEW |