Opened 3 years ago

Closed 3 years ago

Last modified 4 months ago

#4227 closed defect (fixed)

NS_ERROR_ILLEGAL_VALUE on startup (element hiding)

Reported by: trev Assignee: trev
Priority: P1 Milestone: Adblock-Plus-2.8-for-Firefox
Module: Adblock-Plus-for-Firefox Keywords:
Cc: mapx Blocked By:
Blocking: #521 Platform: Unknown / Cross platform
Ready: yes Confidential: no
Tester: Ross Verified working: yes
Review URL(s):

https://codereview.adblockplus.org/29347296/

Description (last modified by trev)

Environment

Firefox 50.0a1 nightly, Adblock Plus 2.7.3.4186

How to reproduce

  1. Start Firefox
  2. Press Ctrl/Cmd-Shift-J to open the Browser Console.

Observed behaviour

Error message coming from elemHide.js line 346:

NS_ERROR_ILLEGAL_VALUE: Component returned failure code: 0x80070057 (NS_ERROR_ILLEGAL_VALUE) [nsIDOMWindowUtils.addSheet]

Expected behaviour

No error messages.

Background

The error is caused by us trying to add the stylesheet twice in some cases.

What to change

Keeping track of documents we dealt with already would create unnecessary overhead. It's better to catch NS_ERROR_ILLEGAL_VALUE and ignore it now that we understand the background of this error.

Change History (7)

comment:1 Changed 3 years ago by trev

It seems that for some reason the stylesheet isn't ready to be used immediately on startup. However, I cannot see any codepath that would return NS_ERROR_ILLEGAL_VALUE: nsDOMWindowUtils::AddSheet itself can only return NS_ERROR_INVALID_POINTER, NS_ERROR_INVALID_ARG and NS_ERROR_FAILURE. It calls into nsDocument::AddAdditionalStyleSheet at the end but that one cannot return anything but NS_ERROR_INVALID_ARG and NS_OK. I suspect that the error code is actually coming from some security wrapper which is supposed to be transparent to us.

comment:2 Changed 3 years ago by trev

I was able to establish that this is unrelated to the stylesheet, the issue is rather the window we try to add it to. Consequently, this error pops up whenever a new browser window is opened, not merely at startup. Not sure yet what kind of windows this affects, it does affect extension windows however like the ones loaded inside a Web Extensions pop-up.

comment:3 Changed 3 years ago by trev

  • Description modified (diff)
  • Owner set to trev

Just great: NS_ERROR_INVALID_ARG and NS_ERROR_ILLEGAL_VALUE are the same thing. This explains how this code can return NS_ERROR_ILLEGAL_VALUE, and it's also fairly easy to see where it comes from. In fact, "content-document-global-created" observer is triggered twice for some documents - and addSheet() will throw NS_ERROR_ILLEGAL_VALUE if you try to re-add a stylesheet.

comment:4 Changed 3 years ago by trev

  • Review URL(s) modified (diff)
  • Status changed from new to reviewing

comment:6 Changed 3 years ago by trev

  • Milestone set to Adblock-Plus-for-Firefox-next
  • Resolution set to fixed
  • Status changed from reviewing to closed

comment:7 Changed 3 years ago by Ross

  • Tester changed from Unknown to Ross
  • Verified working set

Looks fixed / Could not reproduce.

ABP 2.7.3.4198-beta
Nightly 51.0a1 / Windows 7
Firefox 48 / Windows 7

Note: See TracTickets for help on using tickets.