-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathInjectedScriptHost.js
More file actions
104 lines (77 loc) · 2.62 KB
/
InjectedScriptHost.js
File metadata and controls
104 lines (77 loc) · 2.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
"use strict";
(function (binding, DebuggerScript) {
var lastBoundObjectId = 0;
var idToWrappedObject = new Map();
var idToObjectGroupName = new Map();
var nameToObjectGroup = new Map();
function InjectedScriptHost() {
}
InjectedScriptHost.prototype = binding.InjectedScriptHost;
InjectedScriptHost.prototype.bind = function(value, groupName) {
if (lastBoundObjectId <= 0)
lastBoundObjectId = 1;
var id = lastBoundObjectId++;
idToWrappedObject.set(id, value);
if (id < 0) return;
if (groupName == null) return id;
idToObjectGroupName.set(id, groupName);
if (!nameToObjectGroup.has(groupName))
nameToObjectGroup.set(groupName, [id]);
else
nameToObjectGroup.get(groupName).push(id);
return id;
};
InjectedScriptHost.prototype.unbind = function(id) {
idToWrappedObject.delete(id);
idToObjectGroupName.delete(id);
};
InjectedScriptHost.prototype.releaseObject = function(objectId) {
var parsedObjectId;
try {
parsedObjectId = JSON.parse(objectId);
} catch (e) { return; }
this.unbind(parsedObjectId.id);
};
InjectedScriptHost.prototype.releaseObjectGroup = function(groupName) {
if (!groupName) return;
var group = nameToObjectGroup.get(groupName);
if (!group) return;
group.forEach(function(id) {
this.unbind(id);
}, this);
nameToObjectGroup.delete(groupName);
};
InjectedScriptHost.prototype.objectForId = function(id) {
if (!Number(id)) return;
return idToWrappedObject.get(id);
};
InjectedScriptHost.prototype.idToObjectGroupName = function(id) {
if (!Number(id)) return;
return idToObjectGroupName.get(id) || '';
}
InjectedScriptHost.prototype.isHTMLAllCollection = function(object) {
//We don't have `all` collection in NodeJS
return false;
};
InjectedScriptHost.prototype.isDOMWrapper = function(object) {
return false;
};
InjectedScriptHost.prototype.suppressWarningsAndCallFunction = function(func, receiver, args) {
return this.callFunction(func, receiver, args);
};
InjectedScriptHost.prototype.functionDetails = function(fun) {
var details = this.functionDetailsWithoutScopes(fun);
var scopes = DebuggerScript.getFunctionScopes(fun);
if (scopes && scopes.length) {
details.rawScopes = scopes;
}
return details;
};
InjectedScriptHost.prototype.generatorObjectDetails = function(object) {
return DebuggerScript.getGeneratorObjectDetails(object);
};
InjectedScriptHost.prototype.collectionEntries = function(object) {
return DebuggerScript.getCollectionEntries(object);
};
return new InjectedScriptHost();
});