| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 // | 4 // |
| 5 // API test for chrome.tabs.captureVisibleTab() that tests that concurrent | 5 // API test for chrome.tabs.captureVisibleTab() that tests that concurrent |
| 6 // capture requests end up with the expected data (by opening 8 windows with | 6 // capture requests end up with the expected data (by opening 8 windows with |
| 7 // alternating black and white contents and asserting that the captured pixels | 7 // alternating black and white contents and asserting that the captured pixels |
| 8 // are of the expected colors). | 8 // are of the expected colors). |
| 9 // browser_tests.exe --gtest_filter=ExtensionApiTest.CaptureVisibleTabRace | 9 // browser_tests.exe --gtest_filter=ExtensionApiTest.CaptureVisibleTabRace |
| 10 | 10 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 | 57 |
| 58 var testedWindowCount = 0; | 58 var testedWindowCount = 0; |
| 59 windowsAndColors.forEach(function(windowIdAndExpectedColor) { | 59 windowsAndColors.forEach(function(windowIdAndExpectedColor) { |
| 60 var windowId = windowIdAndExpectedColor[0]; | 60 var windowId = windowIdAndExpectedColor[0]; |
| 61 var expectedColor = windowIdAndExpectedColor[1]; | 61 var expectedColor = windowIdAndExpectedColor[1]; |
| 62 chrome.tabs.captureVisibleTab( | 62 chrome.tabs.captureVisibleTab( |
| 63 windowId, | 63 windowId, |
| 64 {'format': 'png'}, | 64 {'format': 'png'}, |
| 65 function(imgDataUrl) { | 65 function(imgDataUrl) { |
| 66 log('captured ' + windowId); | 66 log('captured ' + windowId); |
| 67 if (chrome.extension.lastError) { | 67 if (chrome.runtime.lastError) { |
| 68 chrome.test.fail('captureVisibleTab error: ' + | 68 chrome.test.fail('captureVisibleTab error: ' + |
| 69 chrome.extension.lastError.message); | 69 chrome.runtime.lastError.message); |
| 70 } | 70 } |
| 71 testPixelsAreExpectedColor( | 71 testPixelsAreExpectedColor( |
| 72 imgDataUrl, kWindowRect, expectedColor); | 72 imgDataUrl, kWindowRect, expectedColor); |
| 73 log('tested pixels for ' + windowId); | 73 log('tested pixels for ' + windowId); |
| 74 testedWindowCount++; | 74 testedWindowCount++; |
| 75 if (testedWindowCount == windowsAndColors.length) { | 75 if (testedWindowCount == windowsAndColors.length) { |
| 76 log('test complete'); | 76 log('test complete'); |
| 77 callbackCompleted(); | 77 callbackCompleted(); |
| 78 } | 78 } |
| 79 }); | 79 }); |
| 80 }); | 80 }); |
| 81 }); | 81 }); |
| 82 } | 82 } |
| 83 ]); | 83 ]); |
| OLD | NEW |