Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(1295)

Side by Side Diff: src/com/google/caja/ses/explicit.html

Issue 256790043: Stack traces now capture nested eval info if present. (Closed)
Patch Set: Stack traces now capture nested eval info if present. Created 8 years, 8 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/com/google/caja/ses/debug.js ('k') | src/com/google/caja/ses/useHTMLLogger.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <!DOCTYPE HTML> 1 <!DOCTYPE HTML>
2 2
3 <!-- 3 <!--
4 - Copyright (C) 2011 Google Inc. 4 - Copyright (C) 2011 Google Inc.
5 - 5 -
6 - Licensed under the Apache License, Version 2.0 (the "License"); 6 - Licensed under the Apache License, Version 2.0 (the "License");
7 - you may not use this file except in compliance with the License. 7 - you may not use this file except in compliance with the License.
8 - You may obtain a copy of the License at 8 - You may obtain a copy of the License at
9 - 9 -
10 - http://www.apache.org/licenses/LICENSE-2.0 10 - http://www.apache.org/licenses/LICENSE-2.0
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 })(); 177 })();
178 </script> 178 </script>
179 179
180 <script src="compileExprLater.js"></script> 180 <script src="compileExprLater.js"></script>
181 181
182 <script> 182 <script>
183 (function() { 183 (function() {
184 "use strict"; 184 "use strict";
185 if (!ses.ok()) { return; } 185 if (!ses.ok()) { return; }
186 186
187 var evalOnlySrc =
188 'function evalOnly(str) {\n' +
189 ' debugger;\n' +
190 ' throw Error(str);\n' +
191 '}\n';
192 var fakeUrlSrc =
193 'function fakeUrl(g) {\n' +
194 ' g("Expand me to see stack");\n' +
195 '}\n';
196 var nestedSrc =
197 'cajaVM.confine(\n' +
198 ' "function nested(f) {\\n" + \n' +
199 ' " f(evalOnly);\\n" + \n' +
200 ' "}\\n", {evalOnly: evalOnly})';
187 var exprSrc = 201 var exprSrc =
188 '(function(){\n' + 202 '(function dataUrl(){\n' +
189 ' function foo(str) {\n' + 203 ' nested(fakeUrl);\n' +
190 ' debugger;\n' + 204 '}())';
191 ' throw Error(str);\n' +
192 ' }\n' +
193 ' function foo2(g) { g("Expand me to see stack"); }\n' +
194 ' function foo3(f) { f(foo); }\n' +
195 ' foo3(foo2);\n' +
196 '}())';
197 205
198 syncEval: { 206 syncEval: {
207 var cevalOnly = cajaVM.confine(evalOnlySrc);
208 var cfakeUrl = cajaVM.confine(fakeUrlSrc, void 0, {
209 sourceUrl: 'http://example.com/fake1.js'
210 });
211 var cnested = cajaVM.confine(nestedSrc, {evalOnly: cevalOnly});
199 try { 212 try {
200 cajaVM.confine(exprSrc, {}, { 213 cajaVM.confine(exprSrc, {fakeUrl: cfakeUrl, nested: cnested}, {
201 sourceUrl: 'http://example.com/fake1.js' 214 sourceUrl: 'data:,' + encodeURIComponent(exprSrc)
202 }); 215 });
203 } catch (err) { 216 } catch (err) {
204 // The ses.logger installed by useHTMLLogger.js uses ses.getStack 217 // The ses.logger installed by useHTMLLogger.js uses ses.getStack
205 // to display the stack, if any, associated with the err argument. 218 // to display the stack, if any, associated with the err argument.
206 ses.logger.info('Expected error to test ses.getStack API: ', err); 219 ses.logger.info('Expected error to test ses.getStack API: ', err);
207 break syncEval; 220 break syncEval;
208 } 221 }
209 ses.logger.error('Missing expected error'); 222 ses.logger.error('Missing expected error');
210 } 223 }
211 224
212 var compiledP = ses.compileExprLater(exprSrc, { 225 var eevalOnlyP = ses.confineLater(evalOnlySrc);
226 var efakeUrlP = ses.confineLater(fakeUrlSrc, void 0, {
213 sourceUrl: 'http://example.com/fake2.js' 227 sourceUrl: 'http://example.com/fake2.js'
214 }); 228 });
229 var enestedP = Q(eevalOnlyP).then(function(eevalOnly) {
230 return ses.confineLater(nestedSrc, {evalOnly: eevalOnly});
231 });
232 var doneP = Q.all([efakeUrlP, enestedP]).then(function(efooPair) {
233 var efakeUrl = efooPair[0];
234 var enested = efooPair[1];
235 return ses.confineLater(exprSrc, {
236 fakeUrl: efakeUrl,·
237 nested: enested
238 }, {
239 sourceUrl: 'data:,' + encodeURIComponent(exprSrc)
240 });
241 });
215 // TODO(erights): Should be 'done' once makeQ supports it. 242 // TODO(erights): Should be 'done' once makeQ supports it.
216 Q(compiledP).fcall(cajaVM.sharedImports).then( 243 Q(doneP).then(function(val) {
217 function(val) { 244 ses.logger.error('Missing expected error: ', val);
218 ses.logger.error('Missing expected error: ', val); 245 }, function(reason) {
219 }, 246 // The ses.logger installed by useHTMLLogger.js uses ses.getStack
220 function(reason) { 247 // to display the stack, if any, associated with the err argument.
221 // The ses.logger installed by useHTMLLogger.js uses ses.getStack 248 ses.logger.info('Testing ses.getStack with compileExprLater: ', reason);
222 // to display the stack, if any, associated with the err argument. 249 });
223 ses.logger.info('Testing ses.getStack with compileExprLater: ', reason);
224 });
225 }()); 250 }());
226 </script> 251 </script>
227 252
228 <script src="makeFarResourceMaker.js"></script> 253 <script src="makeFarResourceMaker.js"></script>
229 254
230 <script> 255 <script>
231 (function() { 256 (function() {
232 "use strict"; 257 "use strict";
233 if (!ses.ok()) { return; } 258 if (!ses.ok()) { return; }
234 259
235 var makeTextResource = ses.makeFarResourceMaker(); 260 var makeTextResource = ses.makeFarResourceMaker();
236 261
237 var url = './makeSimpleAMDLoader.js'; 262 var url = './makeSimpleAMDLoader.js';
238 var makeSimpleAMDLoaderFileP = makeTextResource(url); 263 var makeSimpleAMDLoaderFileP = makeTextResource(url);
239 var makeSimpleAMDLoaderSrcP = makeSimpleAMDLoaderFileP.get(); 264 var makeSimpleAMDLoaderSrcP = makeSimpleAMDLoaderFileP.get();
240 265
241 /* We really are evaluating makeSimpleAMDModuleLoader with least 266 /* We really are evaluating makeSimpleAMDModuleLoader with least
242 authority. Even though there's a global compileExprLater, if 267 authority. Even though there's a global compileExprLater, if
243 you don't provide it here, makeSimpleAMDModuleLoader will 268 you don't provide it here, makeSimpleAMDModuleLoader will
244 fail. */ 269 fail. */
245 var imports = cajaVM.makeImports(); 270 var imports = cajaVM.makeImports();
246 cajaVM.copyToImports(imports, { 271 cajaVM.copyToImports(imports, {
247 Q: Q, 272 Q: Q,
248 compileExprLater: ses.compileExprLater 273 compileExprLater: ses.compileExprLater,
274 confineLater: ses.confineLater
249 }); 275 });
250 // NOTE: do not cajaVM.def(imports) for evaluating the 276 // NOTE: Unlike confineLater, do not cajaVM.def(imports) for
251 // simple AMD loader. 277 // evaluating the simple AMD loader.
252 278
253 var makeSimpleAMDLoaderP = Q(makeSimpleAMDLoaderSrcP).then(function(src) { 279 var makeSimpleAMDLoaderP = Q(makeSimpleAMDLoaderSrcP).then(function(src) {
254 var exprSrc = '(function() {' + src + '}).call(this)'; 280 var exprSrc = '(function() {' + src + '}).call(this)';
255 var compiledExprP = ses.compileExprLater(exprSrc, { 281 var compiledExprP = ses.compileExprLater(exprSrc, {
256 sourceUrl: url 282 sourceUrl: url
257 }); 283 });
258 return Q(compiledExprP).then(function(compiledExpr) { 284 return Q(compiledExprP).then(function(compiledExpr) {
259 compiledExpr(imports); 285 compiledExpr(imports);
260 return imports.makeSimpleAMDLoader; 286 return imports.makeSimpleAMDLoader;
261 }); 287 });
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 <script> 329 <script>
304 (function(){ 330 (function(){
305 "use strict"; 331 "use strict";
306 gebi('browserName').textContent = BrowserDetect.browser; 332 gebi('browserName').textContent = BrowserDetect.browser;
307 gebi('browserVersion').textContent = BrowserDetect.version; 333 gebi('browserVersion').textContent = BrowserDetect.version;
308 gebi('browserOS').textContent = BrowserDetect.OS; 334 gebi('browserOS').textContent = BrowserDetect.OS;
309 })(); 335 })();
310 </script> 336 </script>
311 </body> 337 </body>
312 </html> 338 </html>
OLDNEW
« no previous file with comments | « src/com/google/caja/ses/debug.js ('k') | src/com/google/caja/ses/useHTMLLogger.js » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b