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

Side by Side Diff: chrome/test/data/extensions/api_test/stubs/content_script.js

Issue 9460002: Convert app_bindings.js to the schema_generated_bindings.js infrastructure. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: make test extension ID tests pass Created 8 years, 9 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
« no previous file with comments | « chrome/test/data/extensions/api_test/content_scripts/extension_iframe/iframe.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 // Helper function to log message to both the local console and to the 5 // Helper function to log message to both the local console and to the
6 // background page, so that the latter can output the message via the 6 // background page, so that the latter can output the message via the
7 // chrome.test.log() function. 7 // chrome.test.log() function.
8 function logToConsoleAndStdout(msg) { 8 function logToConsoleAndStdout(msg) {
9 console.log(msg); 9 console.log(msg);
10 chrome.extension.sendRequest("log: " + msg); 10 chrome.extension.sendRequest("log: " + msg);
11 } 11 }
12 12
13 // We ask the background page to get the extension API to test against. When it 13 // We ask the background page to get the extension API to test against. When it
14 // responds we start the test. 14 // responds we start the test.
15 console.log("asking for api ..."); 15 console.log("asking for api ...");
16 chrome.extension.sendRequest("getApi", function(apis) { 16 chrome.extension.sendRequest("getApi", function(apis) {
17 console.log("got api response"); 17 console.log("got api response");
18 var privilegedPaths = []; 18 var privilegedPaths = [];
19 var unprivilegedPaths = []; 19 var unprivilegedPaths = [];
20 apis.forEach(function(module) { 20 apis.forEach(function(module) {
21 var namespace = module.namespace; 21 var namespace = module.namespace;
22 22
23 ["functions", "events"].forEach(function(section) { 23 ["functions", "events"].forEach(function(section) {
24 if (typeof(module[section]) == "undefined") 24 if (typeof(module[section]) == "undefined")
25 return; 25 return;
26 module[section].forEach(function(entry) { 26 module[section].forEach(function(entry) {
27 var path = namespace + "." + entry.name; 27 var path = namespace + "." + entry.name;
28 if (entry.unprivileged) { 28 if (module.unprivileged || entry.unprivileged) {
29 unprivilegedPaths.push(path); 29 unprivilegedPaths.push(path);
30 } else { 30 } else {
31 privilegedPaths.push(path); 31 privilegedPaths.push(path);
32 } 32 }
33 }); 33 });
34 }); 34 });
35 35
36 if (module.properties) { 36 if (module.properties) {
37 for (var propName in module.properties) { 37 for (var propName in module.properties) {
38 var path = namespace + "." + propName; 38 var path = namespace + "." + propName;
39 if (module.properties[propName].unprivileged) { 39 if (module.unprivileged || module.properties[propName].unprivileged) {
40 unprivilegedPaths.push(path); 40 unprivilegedPaths.push(path);
41 } else { 41 } else {
42 privilegedPaths.push(path); 42 privilegedPaths.push(path);
43 } 43 }
44 } 44 }
45 } 45 }
46 }); 46 });
47 doTest(privilegedPaths, unprivilegedPaths); 47 doTest(privilegedPaths, unprivilegedPaths);
48 }); 48 });
49 49
(...skipping 12 matching lines...) Expand all
62 try { 62 try {
63 module = module[parts[i]]; 63 module = module[parts[i]];
64 } catch (err) { 64 } catch (err) {
65 logToConsoleAndStdout("testPath failed on " + 65 logToConsoleAndStdout("testPath failed on " +
66 parts.slice(0, i+1).join('.') + '(' + err + ')'); 66 parts.slice(0, i+1).join('.') + '(' + err + ')');
67 return false; 67 return false;
68 } 68 }
69 if (typeof(module) == "undefined") 69 if (typeof(module) == "undefined")
70 return true; 70 return true;
71 } else { 71 } else {
72 // This is the last component - we expect it to either be defined or 72 // This is the last component - we expect it to either be undefined or
73 // to throw an error on access. 73 // to throw an error on access.
74 try { 74 try {
75 if (typeof(module[parts[i]]) == "undefined" && 75 if (typeof(module[parts[i]]) == "undefined" &&
76 path != "extension.lastError") { 76 path != "extension.lastError") {
77 logToConsoleAndStdout(" fail (undefined and not throwing error): " + 77 logToConsoleAndStdout(" fail (undefined and not throwing error): " +
78 path); 78 path);
79 return false; 79 return false;
80 } else if (!expectError) { 80 } else if (!expectError) {
81 return true; 81 return true;
82 } 82 }
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 console.log(success ? "pass" : "fail"); 149 console.log(success ? "pass" : "fail");
150 if (success) { 150 if (success) {
151 reportSuccess(); 151 reportSuccess();
152 } else { 152 } else {
153 logToConsoleAndStdout("failures on:\n" + failures.join("\n") + 153 logToConsoleAndStdout("failures on:\n" + failures.join("\n") +
154 "\n\n\n>>> See comment in stubs_apitest.cc for a " + 154 "\n\n\n>>> See comment in stubs_apitest.cc for a " +
155 "hint about fixing this failure.\n\n"); 155 "hint about fixing this failure.\n\n");
156 reportFailure(); 156 reportFailure();
157 } 157 }
158 } 158 }
OLDNEW
« no previous file with comments | « chrome/test/data/extensions/api_test/content_scripts/extension_iframe/iframe.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698