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

Unified Diff: chrome/test/data/webui/test_api.js

Issue 8480027: Revert 109678 - WebUI test framework: fix Mock4JS verification, allow chrome.send passthrough. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 1 month 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/webui/mock4js_browsertest.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/data/webui/test_api.js
===================================================================
--- chrome/test/data/webui/test_api.js (revision 109679)
+++ chrome/test/data/webui/test_api.js (working copy)
@@ -13,11 +13,6 @@
var testing = {};
(function(exports) {
/**
- * Holds the original version of the |chrome| object.
- */
- var originalChrome = null;
-
- /**
* Hold the currentTestCase across between preLoad and run.
* @type {TestCase}
*/
@@ -343,11 +338,8 @@
* @param {Mock4JS.Mock} mockObject The mock to register callbacks against.
* @param {function(new:Object)} mockClAss Constructor for the mocked class.
* @see registerMessageCallback
- * @see overrideChrome
*/
function registerMockMessageCallbacks(mockObject, mockClass) {
- if (!deferGlobalOverrides && !originalChrome)
- overrideChrome();
var mockProxy = mockObject.proxy();
for (var func in mockClass.prototype) {
if (typeof mockClass.prototype[func] === 'function') {
@@ -564,11 +556,7 @@
try {
currentTestCase.tearDown();
} catch (e) {
- // Caught an exception in tearDown; Register the error and recreate
- // the result if it is passed in.
errors.push(e);
- if (result)
- result = [false, errorsToMessage([e], result[1])];
}
currentTestCase = null;
}
@@ -580,26 +568,6 @@
}
/**
- * Converts each Error in |errors| to a suitable message, adding them to
- * |message|, and returns the message string.
- * @param {Array.<Error>} errors Array of errors to add to |message|.
- * @param {string?} message When supplied, error messages are appended to it.
- * @return {string} |message| + messages of all |errors|.
- */
- function errorsToMessage(errors, message) {
- for (var i = 0; i < errors.length; ++i) {
- var errorMessage = errors[i].stack || errors[i].message;
- if (message)
- message += '\n';
-
- message += 'Failed: ' + currentTestFunction + '(' +
- currentTestArguments.map(JSON.stringify) +
- ')\n' + errorMessage;
- }
- return message;
- }
-
- /**
* Returns [success, message] & clears |errors|.
* @param {boolean} errorsOk When true, errors are ok.
* @return {Array.<boolean, string>}
@@ -607,7 +575,13 @@
function testResult(errorsOk) {
var result = [true, ''];
if (errors.length) {
- result = [!!errorsOk, errorsToMessage(errors)];
+ var message = '';
+ for (var i = 0; i < errors.length; ++i) {
+ message += 'Failed: ' + currentTestFunction + '(' +
+ currentTestArguments.map(JSON.stringify) +
+ ')\n' + errors[i].stack;
+ }
+ result = [!!errorsOk, message];
}
return result;
}
@@ -847,23 +821,6 @@
}
/**
- * Overrides the |chrome| object to enable mocking calls to chrome.send().
- */
- function overrideChrome() {
- if (originalChrome) {
- console.error('chrome object already overridden');
- return;
- }
-
- originalChrome = chrome;
- chrome = {
- __proto__: originalChrome,
- send: send,
- originalSend: originalChrome.send.bind(originalChrome),
- };
- }
-
- /**
* Used by WebUIBrowserTest to preload the javascript libraries at the
* appropriate time for javascript injection into the current page. This
* creates a test case and calls its preLoad for any early initialization such
@@ -878,8 +835,12 @@
function preloadJavascriptLibraries(testFixture, testName) {
deferGlobalOverrides = true;
- window.addEventListener('DOMContentLoaded', function() {
- overrideChrome();
+ exports.addEventListener('DOMContentLoaded', function() {
+ var oldChrome = chrome;
+ chrome = {
+ __proto__: oldChrome,
+ send: send,
+ };
// Override globals at load time so they will be defined.
assertTrue(deferGlobalOverrides);
« no previous file with comments | « chrome/test/data/webui/mock4js_browsertest.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698