diff options
author | rogerta@chromium.org <rogerta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-15 20:21:29 +0000 |
---|---|---|
committer | rogerta@chromium.org <rogerta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-15 20:21:29 +0000 |
commit | 3d094a7ce192719bf7bd7018f8d343aadd31926e (patch) | |
tree | c766ed79d04761831b7ed2c58d647b7adb2a3853 | |
parent | 3f8772441c6fe0d59aff029a162418a70e251b26 (diff) | |
download | chromium_src-3d094a7ce192719bf7bd7018f8d343aadd31926e.zip chromium_src-3d094a7ce192719bf7bd7018f8d343aadd31926e.tar.gz chromium_src-3d094a7ce192719bf7bd7018f8d343aadd31926e.tar.bz2 |
Make it possible to see errors that happens in the stubs test in the stdout of browser_tests.exe, and provide a hint to the user about how to get more information for fixing the error.
BUG=0
TEST=n/a
Review URL: http://codereview.chromium.org/910004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@41623 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/test/data/extensions/api_test/stubs/background.html | 2 | ||||
-rw-r--r-- | chrome/test/data/extensions/api_test/stubs/content_script.js | 24 |
2 files changed, 19 insertions, 7 deletions
diff --git a/chrome/test/data/extensions/api_test/stubs/background.html b/chrome/test/data/extensions/api_test/stubs/background.html index b32d520..e9a4fae 100644 --- a/chrome/test/data/extensions/api_test/stubs/background.html +++ b/chrome/test/data/extensions/api_test/stubs/background.html @@ -5,6 +5,8 @@ chrome.extension.onRequest.addListener(function(msg, sender, responseFunc) { responseFunc(JSON.parse(chrome.test.getApiDefinitions())); } else if (msg == "pass") { chrome.test.notifyPass(); + } else if (msg.substr(0, 3) == "log") { + chrome.test.log(msg); } else { chrome.test.notifyFail("failed"); } 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 0f9ec84..cc34c8d 100644 --- a/chrome/test/data/extensions/api_test/stubs/content_script.js +++ b/chrome/test/data/extensions/api_test/stubs/content_script.js @@ -1,4 +1,12 @@ +// Helper function to log message to both the local console and to the +// background page, so that the latter can output the message via the +// chrome.test.log() function. +function logToConsoleAndStdout(msg) { + console.log(msg); + chrome.extension.sendRequest("log: " + msg); +} + // We ask the background page to get the extension API to test against. When it // responds we start the test. console.log("asking for api ..."); @@ -58,7 +66,7 @@ function testPath(path, expectError) { try { module = module[parts[i]]; } catch (err) { - console.log("testPath failed on subcomponent of " + path); + logToConsoleAndStdout("testPath failed on subcomponent of " + path); return false; } } else { @@ -66,8 +74,8 @@ function testPath(path, expectError) { // to throw an error on access. try { if (typeof(module[parts[i]]) == "undefined") { - console.log(" fail (undefined and not throwing error): " + - path); + logToConsoleAndStdout(" fail (undefined and not throwing error): " + + path); return false; } else if (!expectError) { console.log(" ok (defined): " + path); @@ -75,7 +83,7 @@ function testPath(path, expectError) { } } catch (err) { if (!expectError) { - console.log(" fail (did not expect error): " + path); + logToConsoleAndStdout(" fail (did not expect error): " + path); return false; } var str = err.toString(); @@ -83,13 +91,13 @@ function testPath(path, expectError) { console.log(" ok (correct error thrown): " + path); return true; } else { - console.log(" fail (wrong error: '" + str + "')"); + logToConsoleAndStdout(" fail (wrong error: '" + str + "')"); return false; } } } } - console.log(" fail (no error when we were expecting one): " + path); + logToConsoleAndStdout(" fail (no error when we were expecting one): " + path); return false; } @@ -143,7 +151,9 @@ function doTest(privilegedPaths, unprivilegedPaths) { if (success) { reportSuccess(); } else { - console.log("failures on:\n" + failures.join("\n")); + logToConsoleAndStdout("failures on:\n" + failures.join("\n") + + "\n\n\n>>> See comment in stubs_apitest.cc for a " + + "hint about fixing this failure.\n\n"); reportFailure(); } } |