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

Side by Side Diff: chrome/test/data/webui/test_api.js

Issue 7146024: Use ExecuteJavascriptInWebFrameNotifyResult to return results even in error condition (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Don't check against |this| in the destructor, which doesn't compile on Win. Created 9 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/test/data/webui/sample_downloads.js ('k') | content/renderer/render_view.cc » ('j') | 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 // Library providing basic test framework functionality. 5 // Library providing basic test framework functionality.
6 6
7 (function() { 7 (function() {
8 // Indicates a pass to the C++ backend.
9 function pass() {
10 chrome.send('Pass', []);
11 }
12
13 // Indicates a fail to the C++ backend.
14 function fail(message) {
15 chrome.send('Fail', [String(message)]);
16 }
17
18 // Asserts. 8 // Asserts.
19 // Use the following assertions to verify a condition within a test. 9 // Use the following assertions to verify a condition within a test.
20 // If assertion fails, the C++ backend will be immediately notified. 10 // If assertion fails, the C++ backend will be immediately notified.
21 // If assertion passes, no notification will be sent to the C++ backend. 11 // If assertion passes, no notification will be sent to the C++ backend.
22 function assertBool(test, expected, message) { 12 function assertBool(test, expected, message) {
23 if (test !== expected) { 13 if (test !== expected) {
24 if (message) 14 if (message)
25 message = test + '\n' + message; 15 message = test + '\n' + message;
26 else 16 else
27 message = test; 17 message = test;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 // that have enabled content-security-policy. 49 // that have enabled content-security-policy.
60 currentTest = this[testFunction]; // global object -- not a method. 50 currentTest = this[testFunction]; // global object -- not a method.
61 if (typeof currentTest === "undefined") { 51 if (typeof currentTest === "undefined") {
62 currentTest = eval(testFunction); 52 currentTest = eval(testFunction);
63 } 53 }
64 console.log('Running test ' + currentTest.name); 54 console.log('Running test ' + currentTest.name);
65 currentTest.apply(null, testArguments); 55 currentTest.apply(null, testArguments);
66 } catch (e) { 56 } catch (e) {
67 console.log( 57 console.log(
68 'Failed: ' + currentTest.name + '\nwith exception: ' + e.message); 58 'Failed: ' + currentTest.name + '\nwith exception: ' + e.message);
69 59 return [false, e.message] ;
70 fail(e.message);
71 return;
72 } 60 }
73 61
74 62 return [true];
75 // All tests passed.
76 pass('');
77 } 63 }
78 64
79 // Exports. 65 // Exports.
80 window.assertTrue = assertTrue; 66 window.assertTrue = assertTrue;
81 window.assertFalse = assertFalse; 67 window.assertFalse = assertFalse;
82 window.assertEquals = assertEquals; 68 window.assertEquals = assertEquals;
83 window.assertNotReached = assertNotReached; 69 window.assertNotReached = assertNotReached;
84 window.runTest = runTest; 70 window.runTest = runTest;
85 })(); 71 })();
OLDNEW
« no previous file with comments | « chrome/test/data/webui/sample_downloads.js ('k') | content/renderer/render_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698