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('done'); |
| 19 break; |
| 20 |
| 21 case 'guestCanAccessStorage': |
| 22 // To test access to privileged APIs, the guest attempts to write to local |
| 23 // storage. The guest relays the callbacks for storage.onChanged and |
| 24 // storage.set to the test runner for verification. |
| 25 chrome.storage.onChanged.addListener(function(change) { |
| 26 chrome.runtime.sendMessage({ |
| 27 expected: 42, |
| 28 actual: change.test.newValue, |
| 29 description: 'onStorageChanged' |
| 30 }); |
| 31 }); |
| 32 |
| 33 chrome.storage.local.set({'test': 42}, function() { |
| 34 chrome.storage.local.get('test', function(storage) { |
| 35 chrome.runtime.sendMessage({ |
| 36 expected: 42, |
| 37 actual: storage.test, |
| 38 description: 'onSetAndGet' |
| 39 }); |
| 40 }); |
| 41 }); |
| 42 } |
| 43 }); |
OLD | NEW |