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

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

Issue 10025007: Convert tabs, windows, and extension APIs to feature system. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: blah Created 8 years, 8 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) { 8 function runsWithException(f) {
9 try { 9 try {
10 var foo = f(); 10 var foo = f();
11 console.log('Error: ' + f + '" doesn\'t throw exception.'); 11 console.log('Error: ' + f + '" doesn\'t throw exception.');
12 return false; 12 return false;
13 } catch (e) { 13 } catch (e) {
14 if (e.message.indexOf(' can only be used in extension processes.') > -1) { 14 if (e.message.indexOf(' cannot be used in this context.') > -1) {
15 return true; 15 return true;
16 } else { 16 } else {
17 console.log('Error: incorrect exception message: ' + e.message); 17 console.log('Error: incorrect exception message: ' + e.message);
18 return false; 18 return false;
19 } 19 }
20 } 20 }
21 } 21 }
22 22
23 var success = true; 23 var success = true;
24 24
25 // The whole of chrome.storage (arbitrary unprivileged) is unavailable. 25 // The whole of chrome.storage (arbitrary unprivileged) is unavailable.
26 if (chrome.storage) { 26 if (chrome.storage) {
27 console.log('Error: chrome.storage exists, it shouldn\'t.'); 27 console.log('Error: chrome.storage exists, it shouldn\'t.');
28 success = false; 28 success = false;
29 } 29 }
30 30
31 // Ditto chrome.tabs, though it's special because it's a dependency of the 31 // Ditto all children of chrome.tabs.
32 // partially unprivileged chrome.extension. 32 for (p in chrome.tabs) {
33 if (chrome.tabs) { 33 if (chrome.tabs.hasOwnProperty(p)) {
34 console.log('Error: chrome.tabs exists, it shouldn\'t.'); 34 if (["remove", "create", "update"].indexOf(p) == -1) {
35 success = false; 35 if (!runsWithException(
36 function(p) { return chrome.tabs[p]; }.bind(null, p))) {
37 console.log(p);
38 success = false;
39 break;
40 }
41 }
42 }
36 } 43 }
37 44
38 // Parts of chrome.extension are unavailable. 45 // Parts of chrome.extension are unavailable.
39 if (!runsWithException(function() { return chrome.extension.getViews; })) 46 if (!runsWithException(function() { return chrome.extension.getViews; }))
40 success = false; 47 success = false;
41 48
42 chrome.extension.sendRequest({success: success}); 49 chrome.extension.sendRequest({success: success});
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698