Advertisement
Guest User

Untitled

a guest
Oct 16th, 2019
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.63 KB | None | 0 0
  1. diff --git a/devtools/client/debugger/src/actions/sources/newSources.js b/devtools/client/debugger/src/actions/sources/newSources.js
  2. index f10bbcf7aa3f..7bfb8520f3d1 100644
  3. --- a/devtools/client/debugger/src/actions/sources/newSources.js
  4. +++ b/devtools/client/debugger/src/actions/sources/newSources.js
  5. @@ -291,8 +291,6 @@ export function newGeneratedSources(sourceInfo: Array<GeneratedSourceData>) {
  6. getState,
  7. client,
  8. }: ThunkArgs): Promise<Array<Source>> => {
  9. - const supportsWasm = client.hasWasmSupport();
  10. -
  11. const resultIds = [];
  12. const newSourcesObj = {};
  13. const newSourceActors: Array<SourceActor> = [];
  14. @@ -310,7 +308,7 @@ export function newGeneratedSources(sourceInfo: Array<GeneratedSourceData>) {
  15. introductionUrl: source.introductionUrl,
  16. introductionType: source.introductionType,
  17. isBlackBoxed: false,
  18. - isWasm: !!supportsWasm && source.introductionType === "wasm",
  19. + isWasm: source.introductionType === "wasm",
  20. isExtension: (source.url && isUrlExtension(source.url)) || false,
  21. };
  22. }
  23. diff --git a/devtools/client/debugger/src/client/firefox.js b/devtools/client/debugger/src/client/firefox.js
  24. index d79c76f2b797..471f09dddbb7 100644
  25. --- a/devtools/client/debugger/src/client/firefox.js
  26. +++ b/devtools/client/debugger/src/client/firefox.js
  27. @@ -25,28 +25,20 @@ export async function onConnect(connection: any, actions: Object) {
  28. return;
  29. }
  30.  
  31. - const supportsWasm =
  32. - features.wasm && !!debuggerClient.mainRoot.traits.wasmBinarySource;
  33. -
  34. setupCommands({
  35. threadFront,
  36. tabTarget,
  37. debuggerClient,
  38. - supportsWasm,
  39. });
  40.  
  41. - setupEvents({ threadFront, tabTarget, actions, supportsWasm });
  42. + setupEvents({ threadFront, tabTarget, actions });
  43.  
  44. tabTarget.on("will-navigate", actions.willNavigate);
  45. tabTarget.on("navigate", actions.navigated);
  46.  
  47. - await threadFront.reconfigure({
  48. - observeAsmJS: true,
  49. - pauseWorkersUntilAttach: true,
  50. - wasmBinarySource: supportsWasm,
  51. - skipBreakpoints: prefs.skipPausing,
  52. - logEventBreakpoints: prefs.logEventBreakpoints,
  53. - });
  54. + // I'm removing reconfigure here because it feels redundant
  55. + // 1. a bunch of options are duplicates
  56. + // 2. a bunch of options were static and have been for some time so we can just make assumptions in the server
  57.  
  58. // Retrieve possible event listener breakpoints
  59. actions.getEventListenerBreakpointTypes().catch(e => console.error(e));
  60. diff --git a/devtools/client/debugger/src/client/firefox/commands.js b/devtools/client/debugger/src/client/firefox/commands.js
  61. index 7daea96bc12e..2f168ca41b1e 100644
  62. --- a/devtools/client/debugger/src/client/firefox/commands.js
  63. +++ b/devtools/client/debugger/src/client/firefox/commands.js
  64. @@ -48,29 +48,22 @@ let debuggerClient: DebuggerClient;
  65. let sourceActors: { [ActorId]: SourceId };
  66. let breakpoints: { [string]: Object };
  67. let eventBreakpoints: ?EventListenerActiveList;
  68. -let supportsWasm: boolean;
  69.  
  70. type Dependencies = {
  71. threadFront: ThreadFront,
  72. tabTarget: Target,
  73. debuggerClient: DebuggerClient,
  74. - supportsWasm: boolean,
  75. };
  76.  
  77. function setupCommands(dependencies: Dependencies) {
  78. currentThreadFront = dependencies.threadFront;
  79. currentTarget = dependencies.tabTarget;
  80. debuggerClient = dependencies.debuggerClient;
  81. - supportsWasm = dependencies.supportsWasm;
  82. targets = { worker: {}, contentProcess: {} };
  83. sourceActors = {};
  84. breakpoints = {};
  85. }
  86.  
  87. -function hasWasmSupport() {
  88. - return supportsWasm;
  89. -}
  90. -
  91. function createObjectClient(grip: Grip) {
  92. return debuggerClient.createObjectClient(grip);
  93. }
  94. diff --git a/devtools/client/debugger/src/client/firefox/targets.js b/devtools/client/debugger/src/client/firefox/targets.js
  95. index 04d5ffc7d1c6..5977648e920c 100644
  96. --- a/devtools/client/debugger/src/client/firefox/targets.js
  97. +++ b/devtools/client/debugger/src/client/firefox/targets.js
  98. @@ -5,7 +5,7 @@
  99. // @flow
  100.  
  101. import { addThreadEventListeners } from "./events";
  102. -import { prefs } from "../../utils/prefs";
  103. +import { prefs, asyncStore, features } from "../../utils/prefs";
  104. import type { DebuggerClient, Target } from "./types";
  105. import type { ThreadType } from "../../types";
  106.  
  107. @@ -16,9 +16,45 @@ type Args = {
  108. options: Object,
  109. };
  110.  
  111. +type MainRoot = {
  112. + traits: Object,
  113. +};
  114. +
  115. +// The crux of this proposal is that the debugger gets to say what options the thread cares about.
  116. +// Someday, i hope the logic for options and attaching is pulled into some toolbox level thing, but for now
  117. +// given that we manage attaching to threads here... we might as well own the options as well.
  118. +export async function getTargetOptions(mainRoot: MainRoot) {
  119. + const eventBreakpoints = await asyncStore.eventListenerBreakpoints;
  120. +
  121. + // I'm a bit nervous about this data structure lining up with the shape of `breakpoints`,
  122. + // but it is probably pretty close...
  123. + const breakpoints = await asyncStore.pendingBreakpoints;
  124. +
  125. + const {
  126. + pauseOnExceptions,
  127. + ignoreCaughtExceptions,
  128. + shouldShowOverlay,
  129. + skipBreakpoints,
  130. + logEventBreakpoints,
  131. + } = prefs;
  132. +
  133. + const supportsWasm = features.wasm && !!mainRoot.traits.wasmBinarySource;
  134. +
  135. + return {
  136. + eventBreakpoints,
  137. + breakpoints,
  138. + pauseOnExceptions,
  139. + ignoreCaughtExceptions,
  140. + shouldShowOverlay,
  141. + skipBreakpoints,
  142. + logEventBreakpoints,
  143. + };
  144. +}
  145. +
  146. async function attachTargets(type, targetLists, args) {
  147. const newTargets = {};
  148. const targets = args.targets[type] || {};
  149. + const targetOptions = getTargetOptions(args.debuggerClient.mainRoot);
  150.  
  151. for (const targetFront of targetLists) {
  152. try {
  153. @@ -35,7 +71,7 @@ async function attachTargets(type, targetLists, args) {
  154. // But workers targets are still only managed by the debugger codebase
  155. // and so we have to attach their thread actor
  156. if (!threadFront) {
  157. - [, threadFront] = await targetFront.attachThread(args.options);
  158. + [, threadFront] = await targetFront.attachThread(targetOptions);
  159. // NOTE: resume is not necessary for ProcessDescriptors and can be removed
  160. // once we switch to WorkerDescriptors
  161. threadFront.resume();
  162. diff --git a/devtools/client/debugger/src/utils/test-head.js b/devtools/client/debugger/src/utils/test-head.js
  163. index 09330e4854f4..c8ff83ef803b 100644
  164. --- a/devtools/client/debugger/src/utils/test-head.js
  165. +++ b/devtools/client/debugger/src/utils/test-head.js
  166. @@ -30,10 +30,6 @@ import type { Source, OriginalSourceData, GeneratedSourceData } from "../types";
  167. * @static
  168. */
  169. function createStore(client: any, initialState: any = {}, sourceMapsMock: any) {
  170. - client = {
  171. - hasWasmSupport: () => true,
  172. - ...client,
  173. - };
  174.  
  175. const store = configureStore({
  176. log: false,
  177. diff --git a/devtools/client/framework/toolbox.js b/devtools/client/framework/toolbox.js
  178. index 9d55b4bee606..3558ff221dd2 100644
  179. --- a/devtools/client/framework/toolbox.js
  180. +++ b/devtools/client/framework/toolbox.js
  181. @@ -144,6 +144,10 @@ loader.lazyRequireGetter(
  182. "devtools/client/inspector/node-picker"
  183. );
  184.  
  185. +loader.lazyGetter(this, "getTargetOptions", () =>
  186. + require("devtools/client/debugger/src/firefox/targets")
  187. +)
  188. +
  189. loader.lazyGetter(this, "domNodeConstants", () => {
  190. return require("devtools/shared/dom-node-constants");
  191. });
  192. @@ -639,25 +643,8 @@ Toolbox.prototype = {
  193. },
  194.  
  195. _attachAndResumeThread: async function(target) {
  196. - const [, threadFront] = await target.attachThread({
  197. - autoBlackBox: false,
  198. - ignoreFrameEnvironment: true,
  199. - pauseOnExceptions: Services.prefs.getBoolPref(
  200. - "devtools.debugger.pause-on-exceptions"
  201. - ),
  202. - ignoreCaughtExceptions: Services.prefs.getBoolPref(
  203. - "devtools.debugger.ignore-caught-exceptions"
  204. - ),
  205. - shouldShowOverlay: Services.prefs.getBoolPref(
  206. - "devtools.debugger.features.overlay"
  207. - ),
  208. - skipBreakpoints: Services.prefs.getBoolPref(
  209. - "devtools.debugger.skip-pausing"
  210. - ),
  211. - logEventBreakpoints: Services.prefs.getBoolPref(
  212. - "devtools.debugger.log-event-breakpoints"
  213. - ),
  214. - });
  215. + const targetOptions = getTargetOptions(this.target.client.mainRoot);
  216. + const [, threadFront] = await target.attachThread(targetOptions);
  217.  
  218. try {
  219. await threadFront.resume();
  220. diff --git a/devtools/server/actors/thread.js b/devtools/server/actors/thread.js
  221. index 02b95ec1d6cf..75ebc7b0ffeb 100644
  222. --- a/devtools/server/actors/thread.js
  223. +++ b/devtools/server/actors/thread.js
  224. @@ -357,16 +357,18 @@ const ThreadActor = ActorClassWithSpec(threadSpec, {
  225. if (options.breakpoints) {
  226. this._setBreakpointsOnAttach(options.breakpoints);
  227. }
  228. +
  229. if (options.eventBreakpoints) {
  230. this.setActiveEventBreakpoints(options.eventBreakpoints);
  231. }
  232.  
  233. - this.dbg.enable();
  234. -
  235. - if ("observeAsmJS" in this._options) {
  236. - this.dbg.allowUnobservedAsmJS = !this._options.observeAsmJS;
  237. + if (this._parent.pauseWorkersUntilAttach) {
  238. + this._parent.pauseWorkersUntilAttach(options.pauseWorkersUntilAttach);
  239. }
  240.  
  241. + this.dbg.enable();
  242. + this.dbg.allowUnobservedAsmJS = false;
  243. +
  244. // Notify the parent that we've finished attaching. If this is a worker
  245. // thread which was paused until attaching, this will allow content to
  246. // begin executing.
  247. @@ -665,17 +667,6 @@ const ThreadActor = ActorClassWithSpec(threadSpec, {
  248. return { error: "wrongState" };
  249. }
  250. const options = request.options || {};
  251. -
  252. - if ("observeAsmJS" in options) {
  253. - this.dbg.allowUnobservedAsmJS = !options.observeAsmJS;
  254. - }
  255. -
  256. - if ("pauseWorkersUntilAttach" in options) {
  257. - if (this._parent.pauseWorkersUntilAttach) {
  258. - this._parent.pauseWorkersUntilAttach(options.pauseWorkersUntilAttach);
  259. - }
  260. - }
  261. -
  262. Object.assign(this._options, options);
  263.  
  264. // Update the global source store
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement