Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(894)

Side by Side Diff: chrome/test/data/extensions/api_test/content_scripts/extension_iframe/iframe.js

Issue 14494013: Allow API functions and events to have entries in _api_features.json (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix bug in searching for unprivileged Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 // Simple success test: we want content-script APIs to be available (like 5 // Simple success test: we want content-script APIs to be available (like
6 // sendRequest), but other APIs to be undefined or throw exceptions on access. 6 // sendRequest), but other APIs to be undefined or throw exceptions on access.
7 7
8 function runsWithException(f) {
9 try {
10 var foo = f();
11 console.log('Error: ' + f + '" doesn\'t throw exception.');
12 return false;
13 } catch (e) {
14 if (e.message.indexOf(' can only be used in extension processes.') > -1) {
15 return true;
16 } else {
17 console.log('Error: incorrect exception message: ' + e.message);
18 return false;
19 }
20 }
21 }
22
23 var success = true; 8 var success = true;
24 9
25 // The whole of chrome.storage (arbitrary unprivileged) is unavailable. 10 // The whole of chrome.storage (arbitrary unprivileged) is unavailable.
26 if (chrome.storage) { 11 if (chrome.storage) {
27 console.log('Error: chrome.storage exists, it shouldn\'t.'); 12 console.log('Error: chrome.storage exists, it shouldn\'t.');
28 success = false; 13 success = false;
29 } 14 }
30 15
31 // Ditto chrome.tabs, though it's special because it's a dependency of the 16 // Ditto chrome.tabs, though it's special because it's a dependency of the
32 // partially unprivileged chrome.extension. 17 // partially unprivileged chrome.extension.
33 if (chrome.tabs) { 18 if (chrome.tabs) {
34 console.log('Error: chrome.tabs exists, it shouldn\'t.'); 19 console.log('Error: chrome.tabs exists, it shouldn\'t.');
35 success = false; 20 success = false;
36 } 21 }
37 22
38 // Parts of chrome.extension are unavailable. 23 // Parts of chrome.extension are unavailable.
39 if (!runsWithException(function() { return chrome.extension.getViews; })) 24 if (typeof(chrome.extension.getViews) != 'undefined')
40 success = false; 25 success = false;
41 26
42 chrome.extension.sendRequest({success: success}); 27 chrome.extension.sendRequest({success: success});
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698