diff options
-rw-r--r-- | chrome/test/data/webui/test_api.js | 22 | ||||
-rw-r--r-- | content/browser/webui/web_ui_handler_browsertest.cc | 5 |
2 files changed, 17 insertions, 10 deletions
diff --git a/chrome/test/data/webui/test_api.js b/chrome/test/data/webui/test_api.js index f8d43cd..541ee01 100644 --- a/chrome/test/data/webui/test_api.js +++ b/chrome/test/data/webui/test_api.js @@ -6,13 +6,13 @@ (function() { // Indicates a pass to the C++ backend. - function pass(message) { + function pass() { chrome.send('Pass', []); } // Indicates a fail to the C++ backend. function fail(message) { - chrome.send('Fail', []); + chrome.send('Fail', [String(message)]); } // Asserts. @@ -25,7 +25,7 @@ message = test + '\n' + message; else message = test; - fail(message); + throw new Error(message); } } @@ -39,18 +39,19 @@ function assertEquals(expected, actual, message) { if (expected !== actual) { - fail('Test Error in ' + testName(currentTest) + - '\nActual: ' + actual + '\nExpected: ' + expected + '\n' + message); + throw new Error('Test Error in ' + testName(currentTest) + + '\nActual: ' + actual + '\nExpected: ' + expected + + '\n' + message); } if (typeof expected != typeof actual) { - fail('Test Error in ' + testName(currentTest) + - ' (type mismatch)\nActual Type: ' + typeof actual + - '\nExpected Type:' + typeof expected + '\n' + message); + throw new Error('Test Error in ' + testName(currentTest) + + ' (type mismatch)\nActual Type: ' + typeof actual + + '\nExpected Type:' + typeof expected + '\n' + message); } } function assertNotReached(message) { - fail(message); + throw new Error(message); } // Call this method within your test script file to begin tests. @@ -67,7 +68,8 @@ console.log( 'Failed: ' + currentTest.name + '\nwith exception: ' + e.message); - fail(); + fail(e.message); + return; } } diff --git a/content/browser/webui/web_ui_handler_browsertest.cc b/content/browser/webui/web_ui_handler_browsertest.cc index 0246afe..698daad 100644 --- a/content/browser/webui/web_ui_handler_browsertest.cc +++ b/content/browser/webui/web_ui_handler_browsertest.cc @@ -5,6 +5,7 @@ #include "content/browser/webui/web_ui_handler_browsertest.h" #include "base/utf_string_conversions.h" +#include "base/values.h" #include "chrome/test/ui_test_utils.h" #include "content/browser/renderer_host/render_view_host.h" @@ -24,6 +25,10 @@ void WebUIHandlerBrowserTest::HandleFail(const ListValue* args) { test_succeeded_ = false; if (is_waiting_) MessageLoopForUI::current()->Quit(); + + std::string message; + ASSERT_TRUE(args->GetString(0, &message)); + LOG(INFO) << message; } void WebUIHandlerBrowserTest::RegisterMessages() { |