Chromium Code Reviews| Index: chrome/test/data/extensions/api_test/tabs/no_permissions/test.js |
| diff --git a/chrome/test/data/extensions/api_test/tabs/no_permissions/test.js b/chrome/test/data/extensions/api_test/tabs/no_permissions/test.js |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..bed747b8c08883ff94d2e6ecce733fccea7c34f4 |
| --- /dev/null |
| +++ b/chrome/test/data/extensions/api_test/tabs/no_permissions/test.js |
| @@ -0,0 +1,48 @@ |
| +// Copyright (c) 2013 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 expectedEventData; |
| +var capturedEventData; |
|
not at google - send to devlin
2013/01/09 21:54:31
instead of all this global stuff (variables/onUpda
mvrable
2013/01/09 22:22:59
Done.
|
| + |
| +function onUpdateListener(tabId, info, tab) { |
| + console.log('---onUpdated: ' + info.status + ', ' + info.url); |
|
not at google - send to devlin
2013/01/09 21:54:31
remove logs
mvrable
2013/01/09 22:22:59
Done.
|
| + capturedEventData.push(info); |
| + checkExpectations(); |
| +} |
| + |
| +function checkExpectations() { |
| + if (capturedEventData.length < expectedEventData.length) { |
| + return; |
| + } |
| + chrome.tabs.onUpdated.removeListener(onUpdateListener); |
| + chrome.test.assertEq(JSON.stringify(expectedEventData), |
| + JSON.stringify(capturedEventData)); |
|
not at google - send to devlin
2013/01/09 21:54:31
I think assertEq works with objects?
mvrable
2013/01/09 22:22:59
Done.
|
| + chrome.test.succeed(); |
| +} |
| + |
| +function expect(data, ignoreFunc) { |
| + chrome.tabs.onUpdated.addListener(onUpdateListener); |
| + expectedEventData = data; |
| + capturedEventData = []; |
| +} |
| + |
| +chrome.test.runTests([ |
| + function noOnUpdateUrls() { |
|
not at google - send to devlin
2013/01/09 21:54:31
i'd call these just testOnUpdated/testQuery.
mvrable
2013/01/09 22:22:59
Done.
|
| + expect([ |
| + { status: 'loading' }, |
| + { status: 'complete' } |
| + ]); |
| + chrome.tabs.create({ url: 'chrome://newtab/' }); |
| + }, |
| + |
| + function noQueryUrl() { |
| + chrome.tabs.create({ url: 'chrome://newtab/' }); |
| + chrome.tabs.query({active: true}, chrome.test.callbackPass(function(tabs) { |
| + console.log('---queryActive: ' + JSON.stringify(tabs)); |
| + chrome.test.assertEq(1, tabs.length); |
| + chrome.test.assertEq(undefined, tabs[0].url); |
| + })); |
| + }, |
| + |
| +]); |