From cf10dc032eaae6ae6ac77a12659de33263204d86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Thu, 21 Jun 2018 20:08:40 +0200 Subject: [PATCH] Bug 1470035: Don't reparse cssom sheets, and warn about the reparse being lossy. r=jryans MozReview-Commit-ID: 7j7Tyej0oYn --HG-- extra : rebase_source : dd5966a2a9779175f88ae7448aa337155fe65dcd --- .../server/actors/targets/browsing-context.js | 21 +++++++++++++++++-- .../locales/en-US/browsing-context.properties | 7 +++++++ 2 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 devtools/shared/locales/en-US/browsing-context.properties diff --git a/devtools/server/actors/targets/browsing-context.js b/devtools/server/actors/targets/browsing-context.js index 6e5c3da174aa..85bae4b0b590 100644 --- a/devtools/server/actors/targets/browsing-context.js +++ b/devtools/server/actors/targets/browsing-context.js @@ -35,6 +35,10 @@ const InspectorUtils = require("InspectorUtils"); const EXTENSION_CONTENT_JSM = "resource://gre/modules/ExtensionContent.jsm"; +const { LocalizationHelper } = require("devtools/shared/l10n"); +const STRINGS_URI = "devtools/shared/locales/browsing-context.properties"; +const L10N = new LocalizationHelper(STRINGS_URI); + const { ActorClassWithSpec, Actor } = require("devtools/shared/protocol"); const { browsingContextTargetSpec } = require("devtools/shared/specs/targets/browsing-context"); @@ -1055,11 +1059,24 @@ const browsingContextTargetPrototype = { // Shadow DOM / XBL. const sheets = InspectorUtils.getAllStyleSheets(docShell.document, /* documentOnly = */ true); + const promises = []; for (const sheet of sheets) { - getSheetText(sheet, this._consoleActor).then(text => { + if (InspectorUtils.hasRulesModifiedByCSSOM(sheet)) { + continue; + } + // Reparse the sheet so that we see the existing errors. + promises.push(getSheetText(sheet, this._consoleActor).then(text => { InspectorUtils.parseStyleSheet(sheet, text, /* aUpdate = */ false); - }); + })); } + + Promise.all(promises).then(() => { + this.logInPage({ + text: L10N.getStr("cssSheetsReparsedWarning"), + category: "CSS Parser", + flags: Ci.nsIScriptError.warningFlag, + }); + }); } return {}; diff --git a/devtools/shared/locales/en-US/browsing-context.properties b/devtools/shared/locales/en-US/browsing-context.properties new file mode 100644 index 000000000000..1180496c0515 --- /dev/null +++ b/devtools/shared/locales/en-US/browsing-context.properties @@ -0,0 +1,7 @@ +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +# LOCALIZATION NOTE (cssSheetsReparsedWarning): The warning +# to show after the CSS message filter has been toggled on. +cssSheetsReparsedWarning=Stylesheets without CSSOM changes reparsed to check for errors. Refresh the page to also see errors from stylesheets changed from CSSOM and from style attributes.