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

Side by Side Diff: chrome/test/data/extensions/api_test/bookmarks/api_test.js

Issue 173284: Introduce "testFunction" to reduce boilerplate in extensions API tests.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 3 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 | « no previous file | chrome/test/data/extensions/api_test/bookmarks/test.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Deleted: svn:executable
- *
Added: svn:eol-style
+ LF
OLDNEW
1 // api_test.js 1 // api_test.js
2 // mini-framework for ExtensionApiTest browser tests 2 // mini-framework for ExtensionApiTest browser tests
3 // TODO(erikkay) - figure out a way to share this code across extensions 3 // TODO(erikkay) - figure out a way to share this code across extensions
4 4
5 var completed = false; 5 var completed = false;
6 var tests; 6 var tests;
7 var currentTest; 7 var currentTest;
8 8
9 function complete() { 9 function complete() {
10 completed = true; 10 completed = true;
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 } 73 }
74 fail(message); 74 fail(message);
75 } 75 }
76 } 76 }
77 77
78 function assertNoLastError() { 78 function assertNoLastError() {
79 if (chrome.extension.lastError != undefined) { 79 if (chrome.extension.lastError != undefined) {
80 fail("lastError.message == " + chrome.extension.lastError.message); 80 fail("lastError.message == " + chrome.extension.lastError.message);
81 } 81 }
82 } 82 }
83
84 // Wrapper for generating test functions, that takes care of calling
85 // assertNoLastError() and succeed() for you.
86 function testFunction(func) {
87 return function() {
88 assertNoLastError();
89 try {
90 func.apply(null, arguments);
91 } catch (e) {
92 var stack = null;
93 if (typeof(e.stack) != "undefined") {
94 stack = e.stack.toString()
95 }
96 var msg = "Exception during execution of testFunction in " +
97 currentTest.name;
98 if (stack) {
99 msg += "\n" + stack;
100 } else {
101 msg += "\n(no stack available)";
102 }
103 fail(msg);
104 }
105 succeed();
106 };
107 }
OLDNEW
« no previous file with comments | « no previous file | chrome/test/data/extensions/api_test/bookmarks/test.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698