Opened on 07/04/2016 at 12:34:00 PM

Closed on 07/06/2016 at 05:12:37 PM

Last modified on 07/02/2019 at 11:48:48 AM

#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.

Attachments (0)

Change History (7)

comment:1 Changed on 07/04/2016 at 01:41:03 PM 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 on 07/06/2016 at 12:39:49 PM 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 on 07/06/2016 at 01:35:51 PM 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 on 07/06/2016 at 01:47:32 PM by trev

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

comment:5 Changed on 07/06/2016 at 05:10:57 PM by abpbot

comment:6 Changed on 07/06/2016 at 05:12:37 PM by trev

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

comment:7 Changed on 09/07/2016 at 11:07:54 AM 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

Add Comment

Modify Ticket

Change Properties
Action
as closed .
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from trev.
 
Note: See TracTickets for help on using tickets.