tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit 08bd6d66f6c248f437a6173a3027e1af209c3f83
parent 8569b7016d8fc521b797bff46480b3ebb99808f2
Author: Nicolas Chevobbe <nchevobbe@mozilla.com>
Date:   Tue,  2 Dec 2025 16:39:50 +0000

Bug 2001915 - [devtools] Fix browser_rules_edit-selector-pseudo-element.js intermittent. r=devtools-reviewers,jdescottes

Add a few guard to account for the fact that the node we have an hold on might
have been removed as a result of the selector being modified.

Differential Revision: https://phabricator.services.mozilla.com/D274600

Diffstat:
Mdevtools/client/inspector/rules/test/browser_rules_edit-selector-pseudo-element.js | 2--
Mdevtools/client/inspector/rules/views/rule-editor.js | 10++++++++++
Mdevtools/server/actors/page-style.js | 2+-
3 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/devtools/client/inspector/rules/test/browser_rules_edit-selector-pseudo-element.js b/devtools/client/inspector/rules/test/browser_rules_edit-selector-pseudo-element.js @@ -145,11 +145,9 @@ add_task(async function test_inline_sheet() { info(`Modify ".foo::after" into "h2::after"`); ruleEditor = getRuleViewRuleEditor(view, 0); editor = await focusEditableField(view, ruleEditor.selectorText); - onRuleViewChanged = view.once("ruleview-changed"); const onSelection = inspector.selection.once("new-node-front"); editor.input.value = "h2::after"; EventUtils.synthesizeKey("KEY_Enter"); - await onRuleViewChanged; await onSelection; is( inspector.selection.nodeFront, diff --git a/devtools/client/inspector/rules/views/rule-editor.js b/devtools/client/inspector/rules/views/rule-editor.js @@ -1230,6 +1230,11 @@ RuleEditor.prototype = { try { const response = await this.rule.domRule.modifySelector(element, value); + // Modifying the selector might have removed the element (e.g. for pseudo element) + if (!element.actorID) { + return; + } + // We recompute the list of applied styles, because editing a // selector might cause this rule's position to change. const applied = await elementStyle.pageStyle.getApplied(element, { @@ -1238,6 +1243,11 @@ RuleEditor.prototype = { filter: elementStyle.showUserAgentStyles ? "ua" : undefined, }); + // The element might have been removed while we were trying to get the applied declarations + if (!element.actorID) { + return; + } + this.isEditing = false; const { ruleProps, isMatching } = response; diff --git a/devtools/server/actors/page-style.js b/devtools/server/actors/page-style.js @@ -599,7 +599,7 @@ class PageStyleActor extends Actor { // Assume the consumer has switched context to a new node and no longer // interested in state changes of previous rules. this._observedRules = []; - this.selectedElement = node.rawNode; + this.selectedElement = node?.rawNode || null; if (!node) { return { entries: [] };