Bug 1544170 Part 3 - Inspector changes to fetch style sheets from replaying process, r=pbro.
authorBrian Hackett <bhackett1024@gmail.com>
Fri, 12 Apr 2019 16:36:12 -1000
changeset 470289 5e19fc2158c1875050dd8b79062ade3d2476110d
parent 470288 c04849933658c636fa3b3f3a3521f94141c36b28
child 470290 13cfdfc790a066c147ca19da4eb355d774834db7
push id35892
push userrgurzau@mozilla.com
push dateSat, 20 Apr 2019 09:55:32 +0000
treeherdermozilla-central@a092972b53f0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspbro
bugs1544170
milestone68.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1544170 Part 3 - Inspector changes to fetch style sheets from replaying process, r=pbro. Differential Revision: https://phabricator.services.mozilla.com/D27410
devtools/server/actors/stylesheets.js
--- a/devtools/server/actors/stylesheets.js
+++ b/devtools/server/actors/stylesheets.js
@@ -14,16 +14,20 @@ const {mediaRuleSpec, styleSheetSpec,
 const InspectorUtils = require("InspectorUtils");
 
 loader.lazyRequireGetter(this, "CssLogic", "devtools/shared/inspector/css-logic");
 loader.lazyRequireGetter(this, "addPseudoClassLock",
   "devtools/server/actors/highlighters/utils/markup", true);
 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;
 var TRANSITION_BUFFER_MS = 1000;
 var TRANSITION_RULE_SELECTOR =
 `:root${TRANSITION_PSEUDO_CLASS}, :root${TRANSITION_PSEUDO_CLASS} *`;
 
 var TRANSITION_SHEET = "data:text/css;charset=utf-8," + encodeURIComponent(`
@@ -173,16 +177,23 @@ async function fetchStylesheet(sheet, co
   let result;
   if (consoleActor) {
     result = await consoleActor.getRequestContentForURL(href);
     if (result) {
       return result;
     }
   }
 
+  // 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,
     charset: getCSSCharset(sheet),
   };
 
   // Bug 1282660 - We use the system principal to load the default internal
   // stylesheets instead of the content principal since such stylesheets
@@ -222,17 +233,17 @@ var StyleSheetActor = protocol.ActorClas
   toString: function() {
     return "[StyleSheetActor " + this.actorID + "]";
   },
 
   /**
    * Window of target
    */
   get window() {
-    return this.parentActor.window;
+    return isReplaying ? ReplayInspector.window : this.parentActor.window;
   },
 
   /**
    * Document of target.
    */
   get document() {
     return this.window.document;
   },
@@ -664,17 +675,18 @@ var StyleSheetsActor = protocol.ActorCla
 
   /**
    * Protocol method for getting a list of StyleSheetActors representing
    * all the style sheets in this document.
    */
   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);
     }
     return actors;
   },
 
   /**
    * Check if we should be showing this stylesheet.