From ee403cec3452bd71c803a9df0c157920479b211d Mon Sep 17 00:00:00 2001 From: Brian Hackett Date: Fri, 12 Apr 2019 16:36:12 -1000 Subject: [PATCH] Bug 1544170 Part 3 - Inspector changes to fetch style sheets from replaying process, r=pbro. Differential Revision: https://phabricator.services.mozilla.com/D27410 --HG-- extra : rebase_source : a70fc90d042f7b9d0fdec65aadff911c90f8edf7 --- devtools/server/actors/stylesheets.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/devtools/server/actors/stylesheets.js b/devtools/server/actors/stylesheets.js index 56f1673d6125..96bbd3da4535 100644 --- a/devtools/server/actors/stylesheets.js +++ b/devtools/server/actors/stylesheets.js @@ -19,6 +19,10 @@ loader.lazyRequireGetter(this, "addPseudoClassLock", loader.lazyRequireGetter(this, "removePseudoClassLock", "devtools/server/actors/highlighters/utils/markup", true); loader.lazyRequireGetter(this, "loadSheet", "devtools/shared/layout/utils", true); +loader.lazyRequireGetter(this, "ReplayDebugger", + "devtools/server/actors/replay/debugger"); +loader.lazyRequireGetter(this, "ReplayInspector", + "devtools/server/actors/replay/inspector"); var TRANSITION_PSEUDO_CLASS = ":-moz-styleeditor-transitioning"; var TRANSITION_DURATION_MS = 500; @@ -178,6 +182,13 @@ async function fetchStylesheet(sheet, consoleActor) { } } + // When replaying, fetch the stylesheets from the replaying process, so that + // we get the same sheets which were used when recording. + if (isReplaying) { + const dbg = new ReplayDebugger(); + return dbg.replayingContent(href); + } + const options = { loadFromCache: true, policy: Ci.nsIContentPolicy.TYPE_INTERNAL_STYLESHEET, @@ -227,7 +238,7 @@ var StyleSheetActor = protocol.ActorClassWithSpec(styleSheetSpec, { * Window of target */ get window() { - return this.parentActor.window; + return isReplaying ? ReplayInspector.window : this.parentActor.window; }, /** @@ -669,7 +680,8 @@ var StyleSheetsActor = protocol.ActorClassWithSpec(styleSheetsSpec, { async getStyleSheets() { let actors = []; - for (const win of this.parentActor.windows) { + const windows = isReplaying ? [ReplayInspector.window] : this.parentActor.windows; + for (const win of windows) { const sheets = await this._addStyleSheets(win); actors = actors.concat(sheets); }