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.
5 // This script is opened inside a <extensionoptions> guest view.
7 // This adds a 'loaded' property to the window for the createGuestViewDOM and
8 // createGuestViewProgrammatic tests.
11 // This sends a message back to the test page, which responds with which test
12 // case it is running. The options page then runs the appropriate code for the
13 // specified test case.
14 chrome.runtime.sendMessage('ready', function(command) {
16 case 'canCommunicateWithGuest':
17 // To confirm that the guest view has been successfully created,
18 // {pass: true} is added to every extension Window and broadcasts a
19 // message to the extension using runtime.sendMessage().
20 chrome.extension.getViews().forEach(function(view) {
23 chrome.runtime.sendMessage('done');
26 case 'guestCanAccessStorage':
27 // To test access to privileged APIs, the guest attempts to write to local
28 // storage. The guest relays the callbacks for storage.onChanged and
29 // storage.set to the test runner for verification.
30 chrome.storage.onChanged.addListener(function(change) {
31 chrome.runtime.sendMessage({
33 actual: change.test.newValue,
34 description: 'onStorageChanged'
38 chrome.storage.local.set({'test': 42}, function() {
39 chrome.storage.local.get('test', function(storage) {
40 chrome.runtime.sendMessage({
43 description: 'onSetAndGet'
50 case 'externalLinksOpenInNewTab':
51 var link = document.getElementById('link');
52 chrome.test.runWithUserGesture(function() {
54 chrome.runtime.sendMessage('done');