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

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

Issue 16174005: Implement externally_connectable! Web pages can now communicate directly with (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: absolute path... Created 7 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/test/data/extensions/api_test/messaging/externally_connectable/web_connectable/manifest.json ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/data/extensions/api_test/stubs/content_script.js
diff --git a/chrome/test/data/extensions/api_test/stubs/content_script.js b/chrome/test/data/extensions/api_test/stubs/content_script.js
index c72215ae6bf4babc71904f456b551be3fe676bac..409a6e23c5c08eb39ef2693384ea0eaad24858d8 100644
--- a/chrome/test/data/extensions/api_test/stubs/content_script.js
+++ b/chrome/test/data/extensions/api_test/stubs/content_script.js
@@ -73,46 +73,26 @@ function testPath(path, expectError) {
var module = chrome;
for (var i = 0; i < parts.length; i++) {
if (i < parts.length - 1) {
- // Not the last component. Should not throw an exception, but allowed to
- // be undefined (because some paths are only defined on some platforms).
- try {
- module = module[parts[i]];
- } catch (err) {
- logToConsoleAndStdout("testPath failed on " +
- parts.slice(0, i+1).join('.') + '(' + err + ')');
- return false;
- }
+ // Not the last component. Allowed to be undefined because some paths are
+ // only defined on some platforms.
+ module = module[parts[i]];
if (typeof(module) == "undefined")
return true;
} else {
// This is the last component - we expect it to either be undefined or
// to throw an error on access.
- try {
- if (typeof(module[parts[i]]) == "undefined" &&
- path != "extension.lastError" &&
- path != "runtime.lastError") {
- if (expectError) {
- return true;
- } else {
- logToConsoleAndStdout(" fail (should not be undefined): " + path);
- return false;
- }
- } else if (!expectError) {
- return true;
- }
- } catch (err) {
- if (!expectError) {
- logToConsoleAndStdout(" fail (did not expect error): " + path);
- return false;
- }
- var str = err.toString();
- if (str.search("can only be used in extension processes.") != -1) {
+ if (typeof(module[parts[i]]) == "undefined" &&
+ // lastError being defined depends on there being an error obviously.
+ path != "extension.lastError" &&
+ path != "runtime.lastError") {
+ if (expectError) {
return true;
} else {
- logToConsoleAndStdout(
- "fail: " + path + " (wrong error: '" + str + "')");
+ logToConsoleAndStdout(" fail (should not be undefined): " + path);
return false;
}
+ } else if (!expectError) {
+ return true;
}
}
}
@@ -157,7 +137,12 @@ function doTest(privilegedPaths, unprivilegedPaths) {
// Returns a function that will test a path and record any failures.
function makeTestFunction(expectError) {
return function(path) {
- if (!testPath(path, expectError)) {
+ // runtime.connect and runtime.sendMessage are available in all contexts,
+ // unlike the runtime API in general.
+ var expectErrorForPath = expectError &&
+ path != 'runtime.connect' &&
+ path != 'runtime.sendMessage';
+ if (!testPath(path, expectErrorForPath)) {
success = false;
failures.push(path);
}
« no previous file with comments | « chrome/test/data/extensions/api_test/messaging/externally_connectable/web_connectable/manifest.json ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698