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

Unified 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 side-by-side diff with in-line comments
Download patch
« 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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/inspector/protocol-test.js
diff --git a/test/inspector/protocol-test.js b/test/inspector/protocol-test.js
index ff06a96521c960db4c04d94d24bd6a69b87aa046..c375a7e7a2a6283d1cf7d466ba9b2245510e4807 100644
--- a/test/inspector/protocol-test.js
+++ b/test/inspector/protocol-test.js
@@ -317,3 +317,38 @@ InspectorTest._dispatchMessage = function(messageObject)
InspectorTest.loadScript = function(fileName) {
InspectorTest.addScript(utils.read(fileName));
}
+
+InspectorTest.setupInjectedScriptEnvironment = function(debug) {
+ let scriptSource = '';
+ // First define all getters on Object.prototype.
+ let injectedScriptSource = utils.read('src/inspector/injected-script-source.js');
+ let getterRegex = /\.[a-zA-Z0-9]+/g;
+ let match;
+ let getters = new Set();
+ while (match = getterRegex.exec(injectedScriptSource)) {
+ getters.add(match[0].substr(1));
+ }
+ // TODO(kozyatinskiy): pass builtins to injected script source.
+ getters.delete('constructor');
+ scriptSource += `(function installSettersAndGetters() {
+ let defineProperty = Object.defineProperty;
+ let ObjectPrototype = Object.prototype;\n`;
+ scriptSource += Array.from(getters).map(getter => `
+ defineProperty(ObjectPrototype, '${getter}', {
+ set() { debugger; throw 42; }, get() { debugger; throw 42; },
+ __proto__: null
+ });
+ `).join('\n') + '})();';
+ InspectorTest.addScript(scriptSource);
+
+ if (debug) {
+ InspectorTest.log('WARNING: InspectorTest.setupInjectedScriptEnvironment with debug flag for debugging only and should not be landed.');
+ InspectorTest.log('WARNING: run test with --expose-inspector-scripts flag to get more details.');
+ InspectorTest.setupScriptMap();
+ Protocol.Debugger.enable();
+ Protocol.Debugger.onPaused(message => {
+ let callFrames = message.params.callFrames;
+ InspectorTest.logSourceLocations(callFrames.map(frame => frame.location));
+ })
+ }
+}
« 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