Diff
Modified: releases/WebKitGTK/webkit-2.26/LayoutTests/ChangeLog (250218 => 250219)
--- releases/WebKitGTK/webkit-2.26/LayoutTests/ChangeLog 2019-09-23 10:14:16 UTC (rev 250218)
+++ releases/WebKitGTK/webkit-2.26/LayoutTests/ChangeLog 2019-09-23 10:14:22 UTC (rev 250219)
@@ -1,3 +1,16 @@
+2019-09-03 Devin Rousso <drou...@apple.com>
+
+ REGRESSION (r249078): Flaky crash in com.apple._javascript_Core: Inspector::InjectedScriptModule::ensureInjected
+ https://bugs.webkit.org/show_bug.cgi?id=201201
+ <rdar://problem/54771560>
+
+ Reviewed by Joseph Pecoraro.
+
+ * inspector/debugger/tail-deleted-frames-this-value.html:
+ * inspector/debugger/tail-deleted-frames-this-value-expected.txt:
+ * inspector/debugger/resources/tail-deleted-frames-this-value.js:
+ * inspector/timeline/line-column-expected.txt:
+
2019-09-06 Said Abou-Hallawa <sabouhall...@apple.com>
REGRESSION (r249367): m_decodingPromises grows indefinitely until ImageLoader destruction
Modified: releases/WebKitGTK/webkit-2.26/LayoutTests/inspector/debugger/resources/tail-deleted-frames-this-value.js (250218 => 250219)
--- releases/WebKitGTK/webkit-2.26/LayoutTests/inspector/debugger/resources/tail-deleted-frames-this-value.js 2019-09-23 10:14:16 UTC (rev 250218)
+++ releases/WebKitGTK/webkit-2.26/LayoutTests/inspector/debugger/resources/tail-deleted-frames-this-value.js 2019-09-23 10:14:22 UTC (rev 250219)
@@ -6,12 +6,12 @@
}
function b() {
let y = 40;
- return a.call({aThis: 2});
+ return a.call({aThis: 3});
}
function c() {
let z = 60;
- return b.call({bThis: 1});
+ return b.call({bThis: 2});
}
function startABC() {
- c.call({cThis: 0});
+ c.call({cThis: 1});
}
Modified: releases/WebKitGTK/webkit-2.26/LayoutTests/inspector/debugger/tail-deleted-frames-this-value-expected.txt (250218 => 250219)
--- releases/WebKitGTK/webkit-2.26/LayoutTests/inspector/debugger/tail-deleted-frames-this-value-expected.txt 2019-09-23 10:14:16 UTC (rev 250218)
+++ releases/WebKitGTK/webkit-2.26/LayoutTests/inspector/debugger/tail-deleted-frames-this-value-expected.txt 2019-09-23 10:14:22 UTC (rev 250219)
@@ -6,13 +6,13 @@
------------------------------------
Hit breakpoint at line: 3, column: 4
------------------------------------
-Expected frame: {"functionName":"a","thisValue":["aThis",2],"isTailDeleted":false}
+Expected frame: {"functionName":"a","thisValue":["aThis",3],"isTailDeleted":false}
PASS: 'this' value should have expected property: aThis
PASS: Call Frame 0 'this' value is correct.
-Expected frame: {"functionName":"b","thisValue":["bThis",1],"isTailDeleted":true}
+Expected frame: {"functionName":"b","thisValue":["bThis",2],"isTailDeleted":true}
PASS: 'this' value should have expected property: bThis
PASS: Call Frame 1 'this' value is correct.
-Expected frame: {"functionName":"c","thisValue":["cThis",0],"isTailDeleted":true}
+Expected frame: {"functionName":"c","thisValue":["cThis",1],"isTailDeleted":true}
PASS: 'this' value should have expected property: cThis
PASS: Call Frame 2 'this' value is correct.
Tests done
Modified: releases/WebKitGTK/webkit-2.26/LayoutTests/inspector/debugger/tail-deleted-frames-this-value.html (250218 => 250219)
--- releases/WebKitGTK/webkit-2.26/LayoutTests/inspector/debugger/tail-deleted-frames-this-value.html 2019-09-23 10:14:16 UTC (rev 250218)
+++ releases/WebKitGTK/webkit-2.26/LayoutTests/inspector/debugger/tail-deleted-frames-this-value.html 2019-09-23 10:14:22 UTC (rev 250219)
@@ -34,9 +34,9 @@
// top down list
let expectedFrames = [
- {functionName: 'a', thisValue: ['aThis', 2], isTailDeleted: false},
- {functionName: 'b', thisValue: ['bThis', 1], isTailDeleted: true},
- {functionName: 'c', thisValue: ['cThis', 0], isTailDeleted: true}
+ {functionName: 'a', thisValue: ['aThis', 3], isTailDeleted: false},
+ {functionName: 'b', thisValue: ['bThis', 2], isTailDeleted: true},
+ {functionName: 'c', thisValue: ['cThis', 1], isTailDeleted: true}
];
let targetData = WI.debuggerManager.dataForTarget(WI.debuggerManager.activeCallFrame.target);
Modified: releases/WebKitGTK/webkit-2.26/LayoutTests/inspector/timeline/line-column-expected.txt (250218 => 250219)
--- releases/WebKitGTK/webkit-2.26/LayoutTests/inspector/timeline/line-column-expected.txt 2019-09-23 10:14:16 UTC (rev 250218)
+++ releases/WebKitGTK/webkit-2.26/LayoutTests/inspector/timeline/line-column-expected.txt 2019-09-23 10:14:22 UTC (rev 250219)
@@ -45,7 +45,7 @@
"functionName": "",
"url": "",
"scriptId": "<filtered>",
- "lineNumber": 144,
+ "lineNumber": 140,
"columnNumber": 97
}
],
@@ -107,7 +107,7 @@
"functionName": "",
"url": "",
"scriptId": "<filtered>",
- "lineNumber": 144,
+ "lineNumber": 140,
"columnNumber": 97
}
],
@@ -160,7 +160,7 @@
"functionName": "",
"url": "",
"scriptId": "<filtered>",
- "lineNumber": 144,
+ "lineNumber": 140,
"columnNumber": 97
}
],
@@ -220,7 +220,7 @@
"functionName": "",
"url": "",
"scriptId": "<filtered>",
- "lineNumber": 144,
+ "lineNumber": 140,
"columnNumber": 97
}
],
Modified: releases/WebKitGTK/webkit-2.26/Source/_javascript_Core/ChangeLog (250218 => 250219)
--- releases/WebKitGTK/webkit-2.26/Source/_javascript_Core/ChangeLog 2019-09-23 10:14:16 UTC (rev 250218)
+++ releases/WebKitGTK/webkit-2.26/Source/_javascript_Core/ChangeLog 2019-09-23 10:14:22 UTC (rev 250219)
@@ -1,3 +1,27 @@
+2019-09-03 Devin Rousso <drou...@apple.com>
+
+ REGRESSION (r249078): Flaky crash in com.apple._javascript_Core: Inspector::InjectedScriptModule::ensureInjected
+ https://bugs.webkit.org/show_bug.cgi?id=201201
+ <rdar://problem/54771560>
+
+ Reviewed by Joseph Pecoraro.
+
+ * inspector/InjectedScriptSource.js:
+ (let.InjectedScript.prototype.injectModule):
+ (let.InjectedScript.prototype._evaluateOn):
+ (CommandLineAPI):
+ (let.InjectedScript.prototype.setInspectObject): Deleted.
+ (let.InjectedScript.prototype.addCommandLineAPIGetter): Deleted.
+ (let.InjectedScript.prototype.addCommandLineAPIMethod.func.toString): Deleted.
+ (let.InjectedScript.prototype.addCommandLineAPIMethod): Deleted.
+ (InjectedScript.CommandLineAPI): Deleted.
+ Allow injected script "extensions" (e.g. CommandLineAPIModuleSource.js) to modify objects
+ directly, instead of having them call functions.
+
+ * inspector/InjectedScriptModule.cpp:
+ (Inspector::InjectedScriptModule::ensureInjected):
+ Make sure to reset `hadException` to `false` before making another call.
+
2019-09-01 Yusuke Suzuki <ysuz...@apple.com>
[JSC] Merge op_check_traps into op_enter and op_loop_hint
Modified: releases/WebKitGTK/webkit-2.26/Source/_javascript_Core/inspector/InjectedScriptModule.cpp (250218 => 250219)
--- releases/WebKitGTK/webkit-2.26/Source/_javascript_Core/inspector/InjectedScriptModule.cpp 2019-09-23 10:14:16 UTC (rev 250218)
+++ releases/WebKitGTK/webkit-2.26/Source/_javascript_Core/inspector/InjectedScriptModule.cpp 2019-09-23 10:14:22 UTC (rev 250219)
@@ -72,6 +72,7 @@
function.appendArgument(name());
function.appendArgument(source());
function.appendArgument(host(injectedScriptManager, injectedScript.scriptState()));
+ hadException = false;
resultValue = injectedScript.callFunctionWithEvalEnabled(function, hadException);
if (hadException) {
WTFLogAlways("Failed to parse/execute %s!", name().ascii().data());
Modified: releases/WebKitGTK/webkit-2.26/Source/_javascript_Core/inspector/InjectedScriptSource.js (250218 => 250219)
--- releases/WebKitGTK/webkit-2.26/Source/_javascript_Core/inspector/InjectedScriptSource.js 2019-09-23 10:14:16 UTC (rev 250218)
+++ releases/WebKitGTK/webkit-2.26/Source/_javascript_Core/inspector/InjectedScriptSource.js 2019-09-23 10:14:22 UTC (rev 250219)
@@ -419,22 +419,6 @@
this._inspectObject(object);
}
- setInspectObject(callback)
- {
- this._inspectObject = callback;
- }
-
- addCommandLineAPIGetter(name, func)
- {
- InjectedScript.CommandLineAPI._getters.push({name, func});
- }
-
- addCommandLineAPIMethod(name, func)
- {
- func.toString = function() { return "function " + name + "() { [Command Line API] }" };
- InjectedScript.CommandLineAPI._methods.push({name, func});
- }
-
// InjectedScriptModule C++ API
hasInjectedModule(name)
@@ -449,7 +433,7 @@
let moduleFunction = InjectedScriptHost.evaluate("(" + source + ")");
if (typeof moduleFunction !== "function")
throw "Error: Web Inspector: a function was expected for injectModule";
- moduleFunction.call(inspectedGlobalObject, InjectedScriptHost, inspectedGlobalObject, injectedScriptId, this, RemoteObject, host);
+ moduleFunction(InjectedScriptHost, inspectedGlobalObject, injectedScriptId, this, {RemoteObject, CommandLineAPI}, host);
this._modules[name] = true;
}
@@ -583,7 +567,7 @@
{
let commandLineAPI = null;
if (includeCommandLineAPI)
- commandLineAPI = new InjectedScript.CommandLineAPI(isEvalOnCallFrame ? object : null);
+ commandLineAPI = new CommandLineAPI(isEvalOnCallFrame ? object : null);
return evalFunction.call(object, _expression_, commandLineAPI);
}
@@ -1461,89 +1445,83 @@
// -------
-InjectedScript.CommandLineAPI = class CommandLineAPI
+function CommandLineAPI(callFrame)
{
- constructor(callFrame)
- {
- let savedResultAlias = InjectedScriptHost.savedResultAlias;
+ let savedResultAlias = InjectedScriptHost.savedResultAlias;
- let defineGetter = (key, value) => {
- if (typeof value !== "function") {
- let originalValue = value;
- value = function() { return originalValue; };
- }
+ let defineGetter = (key, value) => {
+ if (typeof value !== "function") {
+ let originalValue = value;
+ value = function() { return originalValue; };
+ }
- this.__defineGetter__("$" + key, value);
- if (savedResultAlias)
- this.__defineGetter__(savedResultAlias + key, value);
- };
+ this.__defineGetter__("$" + key, value);
+ if (savedResultAlias && savedResultAlias !== "$")
+ this.__defineGetter__(savedResultAlias + key, value);
+ };
- if ("_lastResult" in injectedScript)
- defineGetter("_", injectedScript._lastResult);
+ if ("_lastResult" in injectedScript)
+ defineGetter("_", injectedScript._lastResult);
- if ("_exceptionValue" in injectedScript)
- defineGetter("exception", injectedScript._exceptionValue);
+ if ("_exceptionValue" in injectedScript)
+ defineGetter("exception", injectedScript._exceptionValue);
- if ("_eventValue" in injectedScript)
- defineGetter("event", injectedScript._eventValue);
+ if ("_eventValue" in injectedScript)
+ defineGetter("event", injectedScript._eventValue);
- // $1-$99
- for (let i = 1; i <= injectedScript._savedResults.length; ++i) {
- defineGetter(i, function() {
- return injectedScript._savedResults[i];
- });
- }
+ // $1-$99
+ for (let i = 1; i < injectedScript._savedResults.length; ++i)
+ defineGetter(i, injectedScript._savedResults[i]);
- for (let i = 0; i < InjectedScript.CommandLineAPI._getters.length; ++i) {
- let {name, func} = InjectedScript.CommandLineAPI._getters[i];
- defineGetter(name, func);
- }
+ for (let name in CommandLineAPI.getters)
+ defineGetter(name, CommandLineAPI.getters[name]);
- for (let i = 0; i < InjectedScript.CommandLineAPI._methods.length; ++i) {
- let {name, func} = InjectedScript.CommandLineAPI._methods[i];
- this[name] = func;
- }
- }
-};
+ for (let name in CommandLineAPI.methods)
+ this[name] = CommandLineAPI.methods[name];
+}
-InjectedScript.CommandLineAPI._getters = [];
-InjectedScript.CommandLineAPI._methods = [];
+CommandLineAPI.getters = {};
-injectedScript.addCommandLineAPIMethod("keys", function(object) { return Object.keys(object); });
-injectedScript.addCommandLineAPIMethod("values", function(object) { return Object.values(object); });
+CommandLineAPI.methods = {};
-injectedScript.addCommandLineAPIMethod("queryInstances", function() { return InjectedScriptHost.queryInstances(...arguments); });
-injectedScript.addCommandLineAPIMethod("queryObjects", function() { return InjectedScriptHost.queryInstances(...arguments); });
-injectedScript.addCommandLineAPIMethod("queryHolders", function() { return InjectedScriptHost.queryHolders(...arguments); });
+CommandLineAPI.methods["keys"] = function(object) { return Object.keys(object); };
+CommandLineAPI.methods["values"] = function(object) { return Object.values(object); };
-injectedScript.addCommandLineAPIMethod("inspect", function(object) { return injectedScript.inspectObject(object); });
+CommandLineAPI.methods["queryInstances"] = function() { return InjectedScriptHost.queryInstances(...arguments); };
+CommandLineAPI.methods["queryObjects"] = function() { return InjectedScriptHost.queryInstances(...arguments); };
+CommandLineAPI.methods["queryHolders"] = function() { return InjectedScriptHost.queryHolders(...arguments); };
-injectedScript.addCommandLineAPIMethod("assert", function() { return inspectedGlobalObject.console.assert(...arguments); });
-injectedScript.addCommandLineAPIMethod("clear", function() { return inspectedGlobalObject.console.clear(...arguments); });
-injectedScript.addCommandLineAPIMethod("count", function() { return inspectedGlobalObject.console.count(...arguments); });
-injectedScript.addCommandLineAPIMethod("countReset", function() { return inspectedGlobalObject.console.countReset(...arguments); });
-injectedScript.addCommandLineAPIMethod("debug", function() { return inspectedGlobalObject.console.debug(...arguments); });
-injectedScript.addCommandLineAPIMethod("dir", function() { return inspectedGlobalObject.console.dir(...arguments); });
-injectedScript.addCommandLineAPIMethod("dirxml", function() { return inspectedGlobalObject.console.dirxml(...arguments); });
-injectedScript.addCommandLineAPIMethod("error", function() { return inspectedGlobalObject.console.error(...arguments); });
-injectedScript.addCommandLineAPIMethod("group", function() { return inspectedGlobalObject.console.group(...arguments); });
-injectedScript.addCommandLineAPIMethod("groupCollapsed", function() { return inspectedGlobalObject.console.groupCollapsed(...arguments); });
-injectedScript.addCommandLineAPIMethod("groupEnd", function() { return inspectedGlobalObject.console.groupEnd(...arguments); });
-injectedScript.addCommandLineAPIMethod("info", function() { return inspectedGlobalObject.console.info(...arguments); });
-injectedScript.addCommandLineAPIMethod("log", function() { return inspectedGlobalObject.console.log(...arguments); });
-injectedScript.addCommandLineAPIMethod("profile", function() { return inspectedGlobalObject.console.profile(...arguments); });
-injectedScript.addCommandLineAPIMethod("profileEnd", function() { return inspectedGlobalObject.console.profileEnd(...arguments); });
-injectedScript.addCommandLineAPIMethod("record", function() { return inspectedGlobalObject.console.record(...arguments); });
-injectedScript.addCommandLineAPIMethod("recordEnd", function() { return inspectedGlobalObject.console.recordEnd(...arguments); });
-injectedScript.addCommandLineAPIMethod("screenshot", function() { return inspectedGlobalObject.console.screenshot(...arguments); });
-injectedScript.addCommandLineAPIMethod("table", function() { return inspectedGlobalObject.console.table(...arguments); });
-injectedScript.addCommandLineAPIMethod("takeHeapSnapshot", function() { return inspectedGlobalObject.console.takeHeapSnapshot(...arguments); });
-injectedScript.addCommandLineAPIMethod("time", function() { return inspectedGlobalObject.console.time(...arguments); });
-injectedScript.addCommandLineAPIMethod("timeEnd", function() { return inspectedGlobalObject.console.timeEnd(...arguments); });
-injectedScript.addCommandLineAPIMethod("timeLog", function() { return inspectedGlobalObject.console.timeLog(...arguments); });
-injectedScript.addCommandLineAPIMethod("timeStamp", function() { return inspectedGlobalObject.console.timeStamp(...arguments); });
-injectedScript.addCommandLineAPIMethod("trace", function() { return inspectedGlobalObject.console.trace(...arguments); });
-injectedScript.addCommandLineAPIMethod("warn", function() { return inspectedGlobalObject.console.warn(...arguments); });
+CommandLineAPI.methods["inspect"] = function(object) { return injectedScript.inspectObject(object); };
+CommandLineAPI.methods["assert"] = function() { return inspectedGlobalObject.console.assert(...arguments); };
+CommandLineAPI.methods["clear"] = function() { return inspectedGlobalObject.console.clear(...arguments); };
+CommandLineAPI.methods["count"] = function() { return inspectedGlobalObject.console.count(...arguments); };
+CommandLineAPI.methods["countReset"] = function() { return inspectedGlobalObject.console.countReset(...arguments); };
+CommandLineAPI.methods["debug"] = function() { return inspectedGlobalObject.console.debug(...arguments); };
+CommandLineAPI.methods["dir"] = function() { return inspectedGlobalObject.console.dir(...arguments); };
+CommandLineAPI.methods["dirxml"] = function() { return inspectedGlobalObject.console.dirxml(...arguments); };
+CommandLineAPI.methods["error"] = function() { return inspectedGlobalObject.console.error(...arguments); };
+CommandLineAPI.methods["group"] = function() { return inspectedGlobalObject.console.group(...arguments); };
+CommandLineAPI.methods["groupCollapsed"] = function() { return inspectedGlobalObject.console.groupCollapsed(...arguments); };
+CommandLineAPI.methods["groupEnd"] = function() { return inspectedGlobalObject.console.groupEnd(...arguments); };
+CommandLineAPI.methods["info"] = function() { return inspectedGlobalObject.console.info(...arguments); };
+CommandLineAPI.methods["log"] = function() { return inspectedGlobalObject.console.log(...arguments); };
+CommandLineAPI.methods["profile"] = function() { return inspectedGlobalObject.console.profile(...arguments); };
+CommandLineAPI.methods["profileEnd"] = function() { return inspectedGlobalObject.console.profileEnd(...arguments); };
+CommandLineAPI.methods["record"] = function() { return inspectedGlobalObject.console.record(...arguments); };
+CommandLineAPI.methods["recordEnd"] = function() { return inspectedGlobalObject.console.recordEnd(...arguments); };
+CommandLineAPI.methods["screenshot"] = function() { return inspectedGlobalObject.console.screenshot(...arguments); };
+CommandLineAPI.methods["table"] = function() { return inspectedGlobalObject.console.table(...arguments); };
+CommandLineAPI.methods["takeHeapSnapshot"] = function() { return inspectedGlobalObject.console.takeHeapSnapshot(...arguments); };
+CommandLineAPI.methods["time"] = function() { return inspectedGlobalObject.console.time(...arguments); };
+CommandLineAPI.methods["timeEnd"] = function() { return inspectedGlobalObject.console.timeEnd(...arguments); };
+CommandLineAPI.methods["timeLog"] = function() { return inspectedGlobalObject.console.timeLog(...arguments); };
+CommandLineAPI.methods["timeStamp"] = function() { return inspectedGlobalObject.console.timeStamp(...arguments); };
+CommandLineAPI.methods["trace"] = function() { return inspectedGlobalObject.console.trace(...arguments); };
+CommandLineAPI.methods["warn"] = function() { return inspectedGlobalObject.console.warn(...arguments); };
+
+for (let name in CommandLineAPI.methods)
+ CommandLineAPI.methods[name].toString = function() { return "function " + name + "() { [Command Line API] }"; };
+
return injectedScript;
})
Modified: releases/WebKitGTK/webkit-2.26/Source/WebCore/ChangeLog (250218 => 250219)
--- releases/WebKitGTK/webkit-2.26/Source/WebCore/ChangeLog 2019-09-23 10:14:16 UTC (rev 250218)
+++ releases/WebKitGTK/webkit-2.26/Source/WebCore/ChangeLog 2019-09-23 10:14:22 UTC (rev 250219)
@@ -1,3 +1,17 @@
+2019-09-03 Devin Rousso <drou...@apple.com>
+
+ REGRESSION (r249078): Flaky crash in com.apple._javascript_Core: Inspector::InjectedScriptModule::ensureInjected
+ https://bugs.webkit.org/show_bug.cgi?id=201201
+ <rdar://problem/54771560>
+
+ Reviewed by Joseph Pecoraro.
+
+ Tests: inspector/debugger/tail-deleted-frames-this-value.html
+ inspector/heap/getRemoteObject.html
+
+ * inspector/CommandLineAPIModuleSource.js:
+ Avoid executing functions when injecting. Instead, modify the `CommandLineAPI` directly.
+
2019-09-06 Said Abou-Hallawa <sabouhall...@apple.com>
REGRESSION (r249367): m_decodingPromises grows indefinitely until ImageLoader destruction
Modified: releases/WebKitGTK/webkit-2.26/Source/WebCore/inspector/CommandLineAPIModuleSource.js (250218 => 250219)
--- releases/WebKitGTK/webkit-2.26/Source/WebCore/inspector/CommandLineAPIModuleSource.js 2019-09-23 10:14:16 UTC (rev 250218)
+++ releases/WebKitGTK/webkit-2.26/Source/WebCore/inspector/CommandLineAPIModuleSource.js 2019-09-23 10:14:22 UTC (rev 250219)
@@ -28,11 +28,11 @@
//# sourceURL=__InjectedScript_CommandLineAPIModuleSource.js
-(function (InjectedScriptHost, inspectedGlobalObject, injectedScriptId, injectedScript, RemoteObject, CommandLineAPIHost) {
+(function (InjectedScriptHost, inspectedGlobalObject, injectedScriptId, injectedScript, {RemoteObject, CommandLineAPI}, CommandLineAPIHost) {
// FIXME: <https://webkit.org/b/152294> Web Inspector: Parse InjectedScriptSource as a built-in to get guaranteed non-user-overridden built-ins
-injectedScript.setInspectObject(function(object) {
+injectedScript._inspectObject = function(object) {
if (arguments.length === 0)
return;
@@ -53,13 +53,13 @@
}
CommandLineAPIHost.inspect(objectId, hints);
-});
+};
-injectedScript.addCommandLineAPIGetter("0", function() {
+CommandLineAPI.getters["0"] = function() {
return CommandLineAPIHost.inspectedObject();
-});
+};
-injectedScript.addCommandLineAPIMethod("copy", function(object) {
+CommandLineAPI.methods["copy"] = function(object) {
let string = null;
let subtype = RemoteObject.subtype(object);
@@ -70,12 +70,12 @@
else if (injectedScript.isPrimitiveValue(object))
string = "" + object;
else if (typeof object === "symbol")
- string = String(object);
+ string = inspectedGlobalObject.String(object);
else if (typeof object === "function")
string = "" + object;
else {
try {
- string = JSON.stringify(object, null, " ");
+ string = inspectedGlobalObject.JSON.stringify(object, null, " ");
} catch {
string = "" + object;
}
@@ -82,11 +82,11 @@
}
CommandLineAPIHost.copyText(string);
-});
+};
-injectedScript.addCommandLineAPIMethod("getEventListeners", function(target) {
+CommandLineAPI.methods["getEventListeners"] = function(target) {
return CommandLineAPIHost.getEventListeners(target);
-});
+};
function normalizeEventTypes(types) {
if (types === undefined)
@@ -115,7 +115,7 @@
inspectedGlobalObject.console.log(event.type, event);
}
-injectedScript.addCommandLineAPIMethod("monitorEvents", function(object, types) {
+CommandLineAPI.methods["monitorEvents"] = function(object, types) {
if (!object || !object.addEventListener || !object.removeEventListener)
return;
types = normalizeEventTypes(types);
@@ -123,15 +123,15 @@
object.removeEventListener(types[i], logEvent, false);
object.addEventListener(types[i], logEvent, false);
}
-});
+};
-injectedScript.addCommandLineAPIMethod("unmonitorEvents", function(object, types) {
+CommandLineAPI.methods["unmonitorEvents"] = function(object, types) {
if (!object || !object.addEventListener || !object.removeEventListener)
return;
types = normalizeEventTypes(types);
for (let i = 0; i < types.length; ++i)
object.removeEventListener(types[i], logEvent, false);
-});
+};
if (inspectedGlobalObject.document && inspectedGlobalObject.Node) {
function canQuerySelectorOnNode(node) {
@@ -138,7 +138,7 @@
return node && InjectedScriptHost.subtype(node) === "node" && (node.nodeType === inspectedGlobalObject.Node.ELEMENT_NODE || node.nodeType === inspectedGlobalObject.Node.DOCUMENT_NODE || node.nodeType === inspectedGlobalObject.Node.DOCUMENT_FRAGMENT_NODE);
}
- injectedScript.addCommandLineAPIMethod("$", function(selector, start) {
+ CommandLineAPI.methods["$"] = function(selector, start) {
if (canQuerySelectorOnNode(start))
return start.querySelector(selector);
@@ -155,32 +155,35 @@
}
return result;
- });
+ };
- injectedScript.addCommandLineAPIMethod("$$", function(selector, start) {
+ CommandLineAPI.methods["$$"] = function(selector, start) {
if (canQuerySelectorOnNode(start))
- return Array.from(start.querySelectorAll(selector));
- return Array.from(inspectedGlobalObject.document.querySelectorAll(selector));
- });
+ return inspectedGlobalObject.Array.from(start.querySelectorAll(selector));
+ return inspectedGlobalObject.Array.from(inspectedGlobalObject.document.querySelectorAll(selector));
+ };
- injectedScript.addCommandLineAPIMethod("$x", function(xpath, context) {
+ CommandLineAPI.methods["$x"] = function(xpath, context) {
let doc = (context && context.ownerDocument) || inspectedGlobalObject.document;
- var result = doc.evaluate(xpath, context || doc, null, XPathResult.ANY_TYPE, null);
+ let result = doc.evaluate(xpath, context || doc, null, inspectedGlobalObject.XPathResult.ANY_TYPE, null);
switch (result.resultType) {
- case XPathResult.NUMBER_TYPE:
+ case inspectedGlobalObject.XPathResult.NUMBER_TYPE:
return result.numberValue;
- case XPathResult.STRING_TYPE:
+ case inspectedGlobalObject.XPathResult.STRING_TYPE:
return result.stringValue;
- case XPathResult.BOOLEAN_TYPE:
+ case inspectedGlobalObject.XPathResult.BOOLEAN_TYPE:
return result.booleanValue;
- default:
- var nodes = [];
- var node;
- while (node = result.iterateNext())
- nodes.push(node);
- return nodes;
}
- });
+
+ let nodes = [];
+ let node = null;
+ while (node = result.iterateNext())
+ nodes.push(node);
+ return nodes;
+ };
}
+for (let name in CommandLineAPI.methods)
+ CommandLineAPI.methods[name].toString = function() { return "function " + name + "() { [Command Line API] }"; };
+
})