Index: sky/framework/inspector/runtime-agent.sky |
diff --git a/sky/framework/inspector/runtime-agent.sky b/sky/framework/inspector/runtime-agent.sky |
deleted file mode 100644 |
index 62f6a9c2c75d3c6e68e3325e8fa904ef9365e5ed..0000000000000000000000000000000000000000 |
--- a/sky/framework/inspector/runtime-agent.sky |
+++ /dev/null |
@@ -1,135 +0,0 @@ |
-<import src="debug.sky" as="debug" /> |
-<script> |
-class Runtime { |
- constructor(delegate) { |
- this.delegate_ = delegate; |
- Object.preventExtensions(this); |
- } |
- |
- enable() { |
- this.delegate_.sendMessage("Runtime.executionContextCreated", { |
- "context": { |
- "frameId": 1, |
- "id": 1, |
- } |
- }); |
- return { |
- result: true, |
- }; |
- } |
- |
- callFunctionOn(params) { |
- var object = g_objectRegistry.lookup(params.objectId); |
- // This is a horrible hack: |
- var functionName = params.functionDeclaration.match(/^function (\w+)\(/)[1]; |
- var expression = params.functionDeclaration + "; return " + functionName + ";"; |
- var wasThrown = false; |
- var value; |
- try { |
- var func = new Function('', expression)(); |
- value = func(object); |
- } catch (e) { |
- value = e; |
- wasThrown = true; |
- } |
- |
- return makeResult(params, value, wasThrown); |
- } |
- |
- // FIXME: See Blink"s inspected-script-source.js InjectedScript.RemoteObject. |
- evaluate(params) { |
- var wasThrown = false; |
- var value; |
- try { |
- value = eval(params.expression); |
- } catch (e) { |
- value = e; |
- wasThrown = true; |
- } |
- |
- return makeResult(params, value, wasThrown); |
- } |
- |
- getProperties(params) { |
- var properties = injectedScript.getProperties(params.objectId, !!params.ownProperties, !!params.accessorPropertiesOnly); |
- var result = { |
- result: properties |
- }; |
- if (!params.accessorPropertiesOnly) { |
- result.internalProperties = injectedScript.getInternalProperties(params.objectId); |
- } |
- return result; |
- } |
-} |
- |
-// FIXME: This should release all objects associated with an object |
-// group, see InjectedScriptSource.js for an example. Just have to |
-// track which object ids are associated with which object groups first. |
-Runtime.prototype.releaseObjectGroup = debug.loggingStub("releaseObjectGroup"); |
- |
-// See InjectedScript._bind for a fancier version of this: |
- |
-class RemoteObjectRegistery { |
- constructor() { |
- this.lastObjectId = 0; |
- this.objectsById = []; |
- Object.preventExtensions(this); |
- } |
- |
- register(object) { |
- var objectId = ++this.lastObjectId; |
- this.objectsById[objectId] = object; |
- return String(objectId); |
- } |
- |
- lookup(objectId) { |
- return this.objectsById[Number(objectId)]; |
- } |
-} |
- |
-var g_objectRegistry = new RemoteObjectRegistery(); |
- |
-function makeResult(params, value, wasThrown) { |
- var type = typeof(value) |
- var result = { |
- "result": { |
- "type": type, |
- }, |
- "wasThrown": wasThrown, |
- }; |
- |
- // Unclear why this often fails with: |
- // "TypeError: Cannot convert object to primitive value" |
- try { |
- result['result']['description'] = String(value); |
- } catch (e) {} |
- |
- if (type == "object") { |
- result["result"]["objectId"] = g_objectRegistry.register(value); |
- } |
- |
- if (params.returnByValue) { |
- result["result"]["value"] = value; |
- } |
- |
- if (wasThrown) { |
- // If we don"t have exceptionDetails, inspector hits an exception. |
- result["exceptionDetails"] = { |
- "text": value.message, |
- "url": "", |
- "line": 0, |
- "column": 0, |
- "stackTrace": [{ |
- "functionName": "", |
- "scriptId": "1", |
- "url": "", |
- "lineNumber": 0, |
- "columnNumber": 0 |
- }] |
- } |
- } |
- return result; |
-} |
- |
-module.exports = Runtime; |
-</script> |