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

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

Issue 7038046: Insert meta tag turning on content-security-protection for chrome://settings, history, downloads ... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 7 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/browser/resources/options/options.html ('k') | no next file » | 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. 8 // Indicates a pass to the C++ backend.
9 function pass() { 9 function pass() {
10 chrome.send('Pass', []); 10 chrome.send('Pass', []);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 throw new Error('Test Error' + 46 throw new Error('Test Error' +
47 ' (type mismatch)\nActual Type: ' + typeof actual + 47 ' (type mismatch)\nActual Type: ' + typeof actual +
48 '\nExpected Type:' + typeof expected + '\n' + message); 48 '\nExpected Type:' + typeof expected + '\n' + message);
49 } 49 }
50 } 50 }
51 51
52 function assertNotReached(message) { 52 function assertNotReached(message) {
53 throw new Error(message); 53 throw new Error(message);
54 } 54 }
55 55
56 function runTest(currentTest, testArguments) { 56 function runTest(testFunction, testArguments) {
57 try { 57 try {
58 currentTest = eval(currentTest); 58 // Avoid eval() if at all possible, since it will not work on pages
59 // that have enabled content-security-policy.
60 currentTest = this[testFunction]; // global object -- not a method.
61 if (typeof currentTest === "undefined") {
62 currentTest = eval(testFunction);
63 }
abarth-chromium 2011/05/24 21:41:17 Ok. (Probably no { } for the if.)
59 console.log('Running test ' + currentTest.name); 64 console.log('Running test ' + currentTest.name);
60 currentTest.apply(null, testArguments); 65 currentTest.apply(null, testArguments);
61 } catch (e) { 66 } catch (e) {
62 console.log( 67 console.log(
63 'Failed: ' + currentTest.name + '\nwith exception: ' + e.message); 68 'Failed: ' + currentTest.name + '\nwith exception: ' + e.message);
64 69
65 fail(e.message); 70 fail(e.message);
66 return; 71 return;
67 } 72 }
68 73
69 74
70 // All tests passed. 75 // All tests passed.
71 pass(''); 76 pass('');
72 } 77 }
73 78
74 // Exports. 79 // Exports.
75 window.assertTrue = assertTrue; 80 window.assertTrue = assertTrue;
76 window.assertFalse = assertFalse; 81 window.assertFalse = assertFalse;
77 window.assertEquals = assertEquals; 82 window.assertEquals = assertEquals;
78 window.assertNotReached = assertNotReached; 83 window.assertNotReached = assertNotReached;
79 window.runTest = runTest; 84 window.runTest = runTest;
80 })(); 85 })();
OLDNEW
« no previous file with comments | « chrome/browser/resources/options/options.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698