Advertisement
Guest User

Untitled

a guest
Sep 16th, 2019
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.66 KB | None | 0 0
  1. diff --git a/devtools/client/debugger/packages/devtools-reps/src/object-inspector/actions.js b/devtools/client/debugger/packages/devtools-reps/src/object-inspector/actions.js
  2. index 97b47263a7e4..f3a7258bad0a 100644
  3. --- a/devtools/client/debugger/packages/devtools-reps/src/object-inspector/actions.js
  4. +++ b/devtools/client/debugger/packages/devtools-reps/src/object-inspector/actions.js
  5. @@ -7,7 +7,7 @@
  6. import type { GripProperties, Node, Props, ReduxAction } from "./types";
  7.  
  8. const { loadItemProperties } = require("./utils/load-properties");
  9. -const { getLoadedProperties, getActors } = require("./reducer");
  10. +const { getLoadedProperties, getActors, getWatchpoints } = require("./reducer");
  11.  
  12. type Dispatch = ReduxAction => void;
  13.  
  14. @@ -73,38 +73,31 @@ function nodePropertiesLoaded(
  15. };
  16. }
  17.  
  18. -function addWatchpoint(
  19. - item,
  20. - watchpoint: string,
  21. -) {
  22. -
  23. +function addWatchpoint(item, watchpoint: string) {
  24. const buildLabel = item => {
  25. if (item.parent) {
  26. return `${buildLabel(item.parent)}.${item.name}`;
  27. }
  28. return item.name;
  29. };
  30. -
  31. - return async function ({ dispatch, client }: ThunkArgs) {
  32. - let object = item.parent.contents.value;
  33. +
  34. + return async function({ dispatch, client }: ThunkArgs) {
  35. + const object = item.parent.contents.value;
  36. const path = item.parent.path;
  37. const property = item.name;
  38. const label = buildLabel(item);
  39.  
  40. dispatch({
  41. type: "SET_WATCHPOINT",
  42. - data: { path, watchpoint, property },
  43. + data: { path, watchpoint, property, actor: object.actor },
  44. });
  45.  
  46. await client.addWatchpoint(object, property, label, watchpoint);
  47. };
  48. }
  49.  
  50. -function removeWatchpoint(
  51. - item,
  52. -) {
  53. -
  54. - return async function ({ dispatch, client }: ThunkArgs) {
  55. +function removeWatchpoint(item) {
  56. + return async function({ dispatch, client }: ThunkArgs) {
  57. const object = item.parent.contents.value;
  58. const property = item.name;
  59. const path = item.parent.path;
  60. @@ -144,8 +137,11 @@ function rootsChanged(props: Props) {
  61.  
  62. function releaseActors(state, client) {
  63. const actors = getActors(state);
  64. + const watchpoints = getWatchpoints(state);
  65. for (const actor of actors) {
  66. - client.releaseActor(actor);
  67. + if (!watchpoints.has(actor)) {
  68. + client.releaseActor(actor);
  69. + }
  70. }
  71. }
  72.  
  73. diff --git a/devtools/client/debugger/packages/devtools-reps/src/object-inspector/reducer.js b/devtools/client/debugger/packages/devtools-reps/src/object-inspector/reducer.js
  74. index e8a8638f3f9c..966651e2fdea 100644
  75. --- a/devtools/client/debugger/packages/devtools-reps/src/object-inspector/reducer.js
  76. +++ b/devtools/client/debugger/packages/devtools-reps/src/object-inspector/reducer.js
  77. @@ -10,6 +10,7 @@ function initialState() {
  78. loadedProperties: new Map(),
  79. evaluations: new Map(),
  80. actors: new Set(),
  81. + watchpoints: new Map(),
  82. };
  83. }
  84.  
  85. @@ -41,17 +42,15 @@ function reducer(
  86. ownProperties: {
  87. ...obj.ownProperties,
  88. [data.property]: {
  89. - ...obj.ownProperties[data.property],
  90. - watchpoint: data.watchpoint,
  91. - }
  92. - },
  93. - };
  94. + ...obj.ownProperties[data.property],
  95. + watchpoint: data.watchpoint,
  96. + },
  97. + },
  98. + };
  99.  
  100. return cloneState({
  101. - loadedProperties: new Map(state.loadedProperties).set(
  102. - data.path,
  103. - newObj,
  104. - ),
  105. + loadedProperties: new Map(state.loadedProperties).set(data.path, newObj),
  106. + watchpoints: new Map(state.watchpoints).set(data.actor, data.watchpoint),
  107. });
  108. }
  109.  
  110. @@ -63,17 +62,15 @@ function reducer(
  111. ownProperties: {
  112. ...obj.ownProperties,
  113. [data.property]: {
  114. - ...obj.ownProperties[data.property],
  115. - watchpoint: null,
  116. - }
  117. - },
  118. - };
  119. + ...obj.ownProperties[data.property],
  120. + watchpoint: null,
  121. + },
  122. + },
  123. + };
  124.  
  125. return cloneState({
  126. - loadedProperties: new Map(state.loadedProperties).set(
  127. - data.path,
  128. - newObj,
  129. - ),
  130. + loadedProperties: new Map(state.loadedProperties).set(data.path, newObj),
  131. + watchpoints: new Map(state.watchpoints).delete(data.actor),
  132. });
  133. }
  134.  
  135. @@ -110,7 +107,7 @@ function reducer(
  136. // NOTE: we clear the state on resume because otherwise the scopes pane
  137. // would be out of date. Bug 1514760
  138. if (type === "RESUME" || type == "NAVIGATE") {
  139. - return initialState();
  140. + return { ...initialState(), watchpoints: state.watchpoints };
  141. }
  142.  
  143. return state;
  144. @@ -132,6 +129,10 @@ function getActors(state) {
  145. return getObjectInspectorState(state).actors;
  146. }
  147.  
  148. +function getWatchpoints(state) {
  149. + return getObjectInspectorState(state).watchpoints;
  150. +}
  151. +
  152. function getLoadedProperties(state) {
  153. return getObjectInspectorState(state).loadedProperties;
  154. }
  155. @@ -146,6 +147,7 @@ function getEvaluations(state) {
  156.  
  157. const selectors = {
  158. getActors,
  159. + getWatchpoints,
  160. getEvaluations,
  161. getExpandedPathKeys,
  162. getExpandedPaths,
  163. diff --git a/devtools/server/actors/object.js b/devtools/server/actors/object.js
  164. index 7aa67b162ac0..a755efa8fe9d 100644
  165. --- a/devtools/server/actors/object.js
  166. +++ b/devtools/server/actors/object.js
  167. @@ -108,6 +108,11 @@ const proto = {
  168. },
  169.  
  170. addWatchpoint(property, label, watchpointType) {
  171. +
  172. + // promote all objects to the thread level
  173. + console.log(`>> addWatchpoint ${label} ${this.actorID}`)
  174. + this.thread.threadObjectGrip(this);
  175. +
  176. if (this._originalDescriptors.has(property)) {
  177. return;
  178. }
  179. @@ -136,6 +141,7 @@ const proto = {
  180. }),
  181. get: this.obj.makeDebuggeeValue(() => {
  182. pauseAndRespond();
  183. + return desc.value;
  184. }),
  185. });
  186. }
  187. @@ -145,9 +151,12 @@ const proto = {
  188. configurable: desc.configurable,
  189. enumerable: desc.enumerable,
  190. set: this.obj.makeDebuggeeValue(v => {
  191. - desc.value = v;
  192. pauseAndRespond();
  193. + desc.value = v;
  194. }),
  195. + get: this.obj.makeDebuggeeValue(() => {
  196. + return desc.value;
  197. + })
  198. });
  199. }
  200. },
  201. @@ -166,6 +175,14 @@ const proto = {
  202. * Returns a grip for this actor for returning in a protocol message.
  203. */
  204. form: function() {
  205. +
  206. + if (!this.actorID) {
  207. + console.log(`>> object form WTF`, (new Error('')).stack)
  208. + }
  209. +
  210. + console.log(`>> object form ${this.actorID}`)
  211. +
  212. +
  213. const g = {
  214. type: "object",
  215. actor: this.actorID,
  216. @@ -1016,7 +1033,9 @@ const proto = {
  217. * Release the actor, when it isn't needed anymore.
  218. * Protocol.js uses this release method to call the destroy method.
  219. */
  220. - release: function() {},
  221. + release: function() {
  222. + console.log(`>> releasing object actor ${this.actorID}`, (new Error('').stack));
  223. + },
  224. };
  225.  
  226. exports.ObjectActor = protocol.ActorClassWithSpec(objectSpec, proto);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement