Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2014 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 // This script is opened inside a <extensionoptions> guest view. When opened, | |
| 6 // it sends a message back to the test page, which responds with which test case | |
| 7 // it is running. The options page then runs the appropriate code for the | |
| 8 // specified test case. | |
| 9 chrome.runtime.sendMessage('ready', function(command) { | |
| 10 switch (command) { | |
| 11 case 'canCreateExtensionOptionsGuest': | |
| 12 // To confirm that the guest view has been successfully created, | |
| 13 // {pass: true} is added to every extension Window and broadcasts a | |
| 14 // message to the extension using runtime.sendMessage(). | |
| 15 chrome.extension.getViews().forEach(function(view) { | |
| 16 view.pass = true; | |
| 17 }); | |
| 18 chrome.runtime.sendMessage('hi'); | |
|
not at google - send to devlin
2014/07/21 16:30:43
maybe send something less arbitrary-looking? like
ericzeng
2014/07/21 17:52:39
Done.
| |
| 19 break; | |
|
not at google - send to devlin
2014/07/21 16:30:43
nit: new line after the break
ericzeng
2014/07/21 17:52:39
Done.
| |
| 20 case 'guestCanAccessStorage': | |
| 21 // To test access to privileged APIs, the guest attempts to write to local | |
| 22 // storage. The guest relays the callbacks for storage.onChanged and | |
| 23 // storage.set to the test runner for verification. | |
| 24 chrome.storage.onChanged.addListener(function(change) { | |
|
not at google - send to devlin
2014/07/21 16:30:43
listenOnce
ericzeng
2014/07/21 17:52:39
For some reason, using listenOnce causes the the t
not at google - send to devlin
2014/07/21 17:58:59
ah right. it probably runs some testing functions,
| |
| 25 chrome.runtime.sendMessage({ | |
| 26 expected: 42, | |
| 27 actual: change.test.newValue, | |
|
not at google - send to devlin
2014/07/21 16:30:43
nice!
| |
| 28 description: 'onStorage' | |
|
not at google - send to devlin
2014/07/21 16:30:43
nit: 'onChanged' maybe?
ericzeng
2014/07/21 17:52:39
onStorageChanged?
not at google - send to devlin
2014/07/21 17:58:58
sure
| |
| 29 }); | |
| 30 }); | |
| 31 | |
| 32 chrome.storage.local.set({'test': 42}, function() { | |
| 33 chrome.storage.local.get('test', function(storage) { | |
| 34 chrome.runtime.sendMessage({ | |
| 35 expected: 42, | |
| 36 actual: storage.test, | |
| 37 description: 'onSetCallback' | |
|
not at google - send to devlin
2014/07/21 16:30:43
it would be more correct to call this 'onGetCallba
not at google - send to devlin
2014/07/21 16:31:28
or 'onSetAndGet'?
ericzeng
2014/07/21 17:52:39
Let's do onSetAndGet since the test is kind of ver
| |
| 38 }); | |
| 39 }); | |
| 40 }); | |
| 41 } | |
| 42 }); | |
| OLD | NEW |