| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 if (!chrome || !chrome.test) | 5 if (!chrome || !chrome.test) |
| 6 throw new Error('chrome.test is undefined'); | 6 throw new Error('chrome.test is undefined'); |
| 7 | 7 |
| 8 var portNumber; | 8 var portNumber; |
| 9 | 9 |
| 10 // This is a good end-to-end test for two reasons. The first is obvious - it | 10 // This is a good end-to-end test for two reasons. The first is obvious - it |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 chrome.test.assertEq('new title', results[0]); | 117 chrome.test.assertEq('new title', results[0]); |
| 118 chrome.tabs.get(tab.id, tab => { | 118 chrome.tabs.get(tab.id, tab => { |
| 119 chrome.test.assertEq('new title', tab.title); | 119 chrome.test.assertEq('new title', tab.title); |
| 120 chrome.test.succeed(); | 120 chrome.test.succeed(); |
| 121 }); | 121 }); |
| 122 }); | 122 }); |
| 123 }); | 123 }); |
| 124 }, | 124 }, |
| 125 function testLastError() { | 125 function testLastError() { |
| 126 chrome.runtime.setUninstallURL('chrome://newtab', function() { | 126 chrome.runtime.setUninstallURL('chrome://newtab', function() { |
| 127 chrome.test.assertLastError('Invalid URL: "chrome://newtab".'); | 127 var expectedError = 'Invalid URL: "chrome://newtab".'; |
| 128 chrome.test.assertLastError(expectedError); |
| 129 // Explicitly also test the old extension.lastError property. |
| 130 chrome.test.assertTrue(!!chrome.extension.lastError); |
| 131 chrome.test.assertEq(expectedError, chrome.extension.lastError.message); |
| 128 chrome.test.succeed(); | 132 chrome.test.succeed(); |
| 129 }); | 133 }); |
| 130 }, | 134 }, |
| 131 function testStorage() { | 135 function testStorage() { |
| 132 // Check API existence; StorageArea functions. | 136 // Check API existence; StorageArea functions. |
| 133 chrome.test.assertTrue(!!chrome.storage); | 137 chrome.test.assertTrue(!!chrome.storage); |
| 134 chrome.test.assertTrue(!!chrome.storage.local, 'no local'); | 138 chrome.test.assertTrue(!!chrome.storage.local, 'no local'); |
| 135 chrome.test.assertTrue(!!chrome.storage.local.set, 'no set'); | 139 chrome.test.assertTrue(!!chrome.storage.local.set, 'no set'); |
| 136 chrome.test.assertTrue(!!chrome.storage.local.get, 'no get'); | 140 chrome.test.assertTrue(!!chrome.storage.local.get, 'no get'); |
| 137 // Check some properties. | 141 // Check some properties. |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 321 }); | 325 }); |
| 322 }, | 326 }, |
| 323 ]; | 327 ]; |
| 324 | 328 |
| 325 chrome.test.getConfig(config => { | 329 chrome.test.getConfig(config => { |
| 326 chrome.test.assertTrue(!!config, 'config does not exist'); | 330 chrome.test.assertTrue(!!config, 'config does not exist'); |
| 327 chrome.test.assertTrue(!!config.testServer, 'testServer does not exist'); | 331 chrome.test.assertTrue(!!config.testServer, 'testServer does not exist'); |
| 328 portNumber = config.testServer.port; | 332 portNumber = config.testServer.port; |
| 329 chrome.test.runTests(tests); | 333 chrome.test.runTests(tests); |
| 330 }); | 334 }); |
| OLD | NEW |