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

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

Issue 6805003: Add a test for checking that refreshing a page does load the same WebUI page. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 8 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
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. 8 // Indicates a pass to the C++ backend.
9 function pass() { 9 function pass() {
10 chrome.send('Pass', []); 10 chrome.send('Pass', []);
(...skipping 21 matching lines...) Expand all
32 function assertTrue(test, message) { 32 function assertTrue(test, message) {
33 assertBool(test, true, message); 33 assertBool(test, true, message);
34 } 34 }
35 35
36 function assertFalse(test, message) { 36 function assertFalse(test, message) {
37 assertBool(test, false, message); 37 assertBool(test, false, message);
38 } 38 }
39 39
40 function assertEquals(expected, actual, message) { 40 function assertEquals(expected, actual, message) {
41 if (expected !== actual) { 41 if (expected !== actual) {
42 throw new Error('Test Error in ' + testName(currentTest) + 42 throw new Error('Test Error. Actual: ' + actual + '\nExpected: ' +
43 '\nActual: ' + actual + '\nExpected: ' + expected + 43 expected + '\n' + message);
44 '\n' + message);
45 } 44 }
46 if (typeof expected != typeof actual) { 45 if (typeof expected != typeof actual) {
47 throw new Error('Test Error in ' + testName(currentTest) + 46 throw new Error('Test Error' +
48 ' (type mismatch)\nActual Type: ' + typeof actual + 47 ' (type mismatch)\nActual Type: ' + typeof actual +
49 '\nExpected Type:' + typeof expected + '\n' + message); 48 '\nExpected Type:' + typeof expected + '\n' + message);
50 } 49 }
51 } 50 }
52 51
53 function assertNotReached(message) { 52 function assertNotReached(message) {
54 throw new Error(message); 53 throw new Error(message);
55 } 54 }
56 55
57 function runTest(currentTest) { 56 function runTest(currentTest) {
58 try { 57 try {
59 console.log('Running test ' + currentTest.name); 58 console.log('Running test ' + currentTest.name);
60 currentTest.call(); 59 currentTest.call();
61 } catch (e) { 60 } catch (e) {
62 console.error( 61 console.log(
63 'Failed: ' + currentTest.name + '\nwith exception: ' + e.message); 62 'Failed: ' + currentTest.name + '\nwith exception: ' + e.message);
64 63
65 fail(e.message); 64 fail(e.message);
66 return; 65 return;
67 } 66 }
68 67
69 68
70 // All tests passed. 69 // All tests passed.
71 pass(''); 70 pass('');
72 } 71 }
73 72
74 // Exports. 73 // Exports.
75 window.assertTrue = assertTrue; 74 window.assertTrue = assertTrue;
76 window.assertFalse = assertFalse; 75 window.assertFalse = assertFalse;
77 window.assertEquals = assertEquals; 76 window.assertEquals = assertEquals;
78 window.assertNotReached = assertNotReached; 77 window.assertNotReached = assertNotReached;
79 window.runTest = runTest; 78 window.runTest = runTest;
80 })(); 79 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698