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

Side by Side Diff: test/inspector/protocol-test.js

Issue 2770823003: [inspector] Increased chances of successful InjectedScriptSource compilation (Closed)
Patch Set: fixed .isolate Created 3 years, 9 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
OLDNEW
1 // Copyright 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 the V8 project 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 InspectorTest = {}; 5 InspectorTest = {};
6 InspectorTest._dispatchTable = new Map(); 6 InspectorTest._dispatchTable = new Map();
7 InspectorTest._requestId = 0; 7 InspectorTest._requestId = 0;
8 InspectorTest._dumpInspectorProtocolMessages = false; 8 InspectorTest._dumpInspectorProtocolMessages = false;
9 InspectorTest._eventHandler = {}; 9 InspectorTest._eventHandler = {};
10 InspectorTest._commandsForLogging = new Set(); 10 InspectorTest._commandsForLogging = new Set();
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 } 310 }
311 } catch (e) { 311 } catch (e) {
312 InspectorTest.log("Exception when dispatching message: " + e + "\n" + e.stac k + "\n message = " + JSON.stringify(messageObject, null, 2)); 312 InspectorTest.log("Exception when dispatching message: " + e + "\n" + e.stac k + "\n message = " + JSON.stringify(messageObject, null, 2));
313 InspectorTest.completeTest(); 313 InspectorTest.completeTest();
314 } 314 }
315 } 315 }
316 316
317 InspectorTest.loadScript = function(fileName) { 317 InspectorTest.loadScript = function(fileName) {
318 InspectorTest.addScript(utils.read(fileName)); 318 InspectorTest.addScript(utils.read(fileName));
319 } 319 }
320
321 InspectorTest.setupInjectedScriptEnvironment = function(debug) {
322 let scriptSource = '';
323 // First define all getters on Object.prototype.
324 let injectedScriptSource = utils.read('src/inspector/injected-script-source.js ');
325 let getterRegex = /\.[a-zA-Z0-9]+/g;
326 let match;
327 let getters = new Set();
328 while (match = getterRegex.exec(injectedScriptSource)) {
329 getters.add(match[0].substr(1));
330 }
331 // TODO(kozyatinskiy): pass builtins to injected script source.
332 getters.delete('constructor');
333 scriptSource += `(function installSettersAndGetters() {
334 let defineProperty = Object.defineProperty;
335 let ObjectPrototype = Object.prototype;\n`;
336 scriptSource += Array.from(getters).map(getter => `
337 defineProperty(ObjectPrototype, '${getter}', {
338 set() { debugger; throw 42; }, get() { debugger; throw 42; },
339 __proto__: null
340 });
341 `).join('\n') + '})();';
342 InspectorTest.addScript(scriptSource);
343
344 if (debug) {
345 InspectorTest.log('WARNING: InspectorTest.setupInjectedScriptEnvironment wit h debug flag for debugging only and should not be landed.');
346 InspectorTest.log('WARNING: run test with --expose-inspector-scripts flag to get more details.');
347 InspectorTest.setupScriptMap();
348 Protocol.Debugger.enable();
349 Protocol.Debugger.onPaused(message => {
350 let callFrames = message.params.callFrames;
351 InspectorTest.logSourceLocations(callFrames.map(frame => frame.location));
352 })
353 }
354 }
OLDNEW
« no previous file with comments | « test/inspector/inspector.isolate ('k') | test/inspector/runtime/runtime-evaluate-with-dirty-context.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698