| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 var theOnlyTestDone = null; | 5 var theOnlyTestDone = null; |
| 6 | 6 |
| 7 function inject(callback) { | 7 function inject(callback) { |
| 8 chrome.tabs.executeScript({ code: "true" }, callback); | 8 chrome.tabs.executeScript({ code: "true" }, callback); |
| 9 } | 9 } |
| 10 | 10 |
| 11 chrome.browserAction.onClicked.addListener(function() { | 11 chrome.browserAction.onClicked.addListener(function() { |
| 12 inject(function() { | 12 inject(function() { |
| 13 chrome.test.assertNoLastError(); | 13 chrome.test.assertNoLastError(); |
| 14 chrome.test.notifyPass(); | 14 chrome.test.notifyPass(); |
| 15 }); | 15 }); |
| 16 }); | 16 }); |
| 17 | 17 |
| 18 chrome.webNavigation.onCompleted.addListener(function(details) { | 18 chrome.webNavigation.onCompleted.addListener(function(details) { |
| 19 inject(function() { | 19 inject(function() { |
| 20 chrome.test.assertLastError("Access to extension API denied."); | 20 chrome.test.assertLastError('Cannot access contents of url "' + |
| 21 details.url + |
| 22 '". Extension manifest must request permission to access this host.'); |
| 21 if (details.url.indexOf("final_page") >= 0) | 23 if (details.url.indexOf("final_page") >= 0) |
| 22 theOnlyTestDone(); | 24 theOnlyTestDone(); |
| 23 else | 25 else |
| 24 chrome.test.notifyPass(); | 26 chrome.test.notifyPass(); |
| 25 }); | 27 }); |
| 26 }); | 28 }); |
| 27 | 29 |
| 28 chrome.test.runTests([ | 30 chrome.test.runTests([ |
| 29 function theOnlyTest() { | 31 function theOnlyTest() { |
| 30 // This will keep the test alive until the final callback is run. | 32 // This will keep the test alive until the final callback is run. |
| 31 theOnlyTestDone = chrome.test.callbackAdded(); | 33 theOnlyTestDone = chrome.test.callbackAdded(); |
| 32 } | 34 } |
| 33 ]); | 35 ]); |
| OLD | NEW |