Closed Bug 1423300 Opened 8 years ago Closed 2 years ago

Error: Permission denied to access property "mediaText"

Categories

(Core :: DOM: Bindings (WebIDL), defect)

56 Branch
defect

Tracking

()

RESOLVED WORKSFORME

People

(Reporter: ab, Unassigned)

References

Details

(Whiteboard: [domcore-bugbash-triaged])

User Agent: Mozilla/5.0 (X11; Linux x86_64; rv:56.0) Gecko/20100101 Firefox/56.0 Build ID: 20170914024831 Steps to reproduce: I'm encountering the `Error: Permission denied to access property "mediaText"` error message, and it happens only in Firefox 56.0b12, not in Firefox 52.5 nor Chrome 62. It happens when I try this: ```js const media = document.styleSheets[i].media; if (mediaType === 'object') { if (media.hasOwnProperty('mediaText') && (media.mediaText === '' || (media.mediaText.indexOf('screen') !== -1))) { styleSheet = document.styleSheets[i]; } } ``` Actual results: while `mediaText` always exists and can be seen in the console, merely trying to access it from the script results in that error above.
Component: Untriaged → DOM
Product: Firefox → Core
Scratch my previous comment. The code in the previous comment results in a slightly different error message: `Error: Permission denied to access property "hasOwnProperty"`. I do get the `Error: Permission denied to access property "mediaText"` error message with this code: ```js const media = document.styleSheets[i].media; if (mediaType === 'object') { if (media.mediaText === '' || (media.mediaText.indexOf('screen') !== -1)) { styleSheet = document.styleSheets[i]; } }
To be more precise, that bug does not appears in Firefox 58.0b8 nor 58.0b9.
(In reply to AciD from comment #2) > To be more precise, that bug does not appears in Firefox 58.0b8 nor 58.0b9. Well I jumped the gun a bit early, after refreshing the page and server, I still get the `Error: Permission denied to access property "hasOwnProperty"` error message with the latest `v58.0b9` version..
Hi Xidorn, I saw you wrote and reviewed quite a lot for MediaList related code, so guessing you might be a person to ask for taking a look at. :)
Flags: needinfo?(xidorn+moz)
Sorry, somehow I missed the email... It is not clear to me about how can I reproduce this issue. I tried to get document.styleSheets[0].media.mediaText of this bugzilla page, and everything seems to work just fine. AciD, could you provide a more detailed steps to reproduce this issue reliably?
Flags: needinfo?(xidorn+moz) → needinfo?(ab)
Well, I have a complex setup with Require.js + laravel 5.1. I'll try to create a simple reproducible test case whenever I get the time.
Flags: needinfo?(ab)
Flags: needinfo?(ab)
Priority: -- → P3
Component: DOM → DOM: Core & HTML

I can reproduce this error, or at least a similar one. We ran into it with a customer report of an error in BrowserLink in Visual Studio.

I've created a minimal repro that works with just one html file and one css file:

<!DOCTYPE html>
<html>
    <head>
        <meta content="text/html;charset=utf-8" http-equiv="Content-Type">
        <meta content="utf-8" http-equiv="encoding">
        <link rel="stylesheet" href="FirefoxReproStyles.css" />
    </head>
    <body>
        <h1>Some Text</h1>
        <p><a href="#" onclick="ProcessStyles();return false;">Click Me</a></p>
    </body>
    <script>
        function ProcessStyles() {
            const media = document.styleSheets[0].media;
            let mt = media.mediaText;
            console.log(mt);
        }
    </script>
</html>

FirefoxReproStyles.css:

@media all and (min-width: 1000px) {
    h1 {
      font-size: 3.5rem; }
    h2 {
      font-size: 2.5rem; }
    h3 {
      font-size: 2rem; } 
}

The steps here are pretty simple, but specific:

  1. Load the page in Firefox.
  2. Right-click on the big "Some Text" at the top and choose Inspect Element
  3. Click the "Click Me" link to execute the script block.
  4. Look in the console output and you'll see the OP's exception message.

Interestingly, if you replace step 2 with just hitting F12, the problem does not happen, at least not immediately. A combination of inspecting the element from the Inspect tab and hitting refresh on the browser will cause it to happen eventually.

I tested this on 70.0b8 (64-bit) on Windows 10 initially.
I confirmed it was also an issue on:
Developer: 70.0b8 (64-bit) and
Nightly: 71.0a1 (2019-09-19) (64-bit)

The error does not happen in Chrome or Chromium-based Edge. I did not test other browsers.

Based on the steps in comment 8, I can reproduce this bug. It doesn't seem to happen very reliably. Need further investigation.

Status: UNCONFIRMED → NEW
Ever confirmed: true

Sorry I couldn't find the time to create a reproducible test case.
Luckily Tim apparently found the cause of this heisenbug, that's great!

The issue I mentioned 2 years ago is still open and CodeKit's maintainer summed up the problem here.
As you can see from this single thread, that bug as affected a number of devs.
It would be great to be able to work with the Firefox console open!

I looked into this a bit, and it doesn't seem to me that there is anything related to our CSSOM implementation. It seems that there is somewhere in the binding code that thinks the value returned from media should be restricted in some cases. I'm not very familiar with binding code so it probably need someone who knows the internal of JS more to investigate.

Moving this to binding so that someone with expertise there could shed some light.

Component: DOM: Core & HTML → DOM: Bindings (WebIDL)
Priority: P3 → --

I have found a case where this bug always occurs. Using Salvattore, a library agnostic JS script, this bug always shows up when Web Console (Ctrl+Shift+K) is opened and reload a page with Salvattore javascript. I'm using Salvattore on a new website project I'm currently working on and I'm using Firefox Web Developer Tools to debug, which is how I came across this bug.

https://salvattore.js.org
https://github.com/rnmp/salvattore

User Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:82.0) Gecko/20100101 Firefox/82.0
Build ID: 20201014125134

Reproducible: Always

Steps to Reproduce:

  1. Open a website with Salvattore js, for example https://salvattore.js.org
  2. Open Web Console (Ctrl+Shift+K)
  3. Reload the page

Actual Results:
The javascript for Salvattore has stopped with error.
This message is displayed in Web Console:


Uncaught Error: Permission denied to access property "mediaText"
v https://salvattore.js.org/site.js:1
v https://salvattore.js.org/site.js:1
v https://salvattore.js.org/site.js:1
m https://salvattore.js.org/site.js:1
<anonymous> https://salvattore.js.org/site.js:1
i https://salvattore.js.org/site.js:1
b https://salvattore.js.org/site.js:1
i https://salvattore.js.org/site.js:1
b https://salvattore.js.org/site.js:1
i https://salvattore.js.org/site.js:1
s https://salvattore.js.org/site.js:1
setTimeout handler*s https://salvattore.js.org/site.js:1
<anonymous> https://salvattore.js.org/site.js:1
<anonymous> https://salvattore.js.org/site.js:1

Expected Results:
The javascript for Salvattore is executed.

You have to close Web Console and Web Developer window, then reload the page to make Salvattore javacript run normal.
This bug never occurs when Web Console and Web Developer window is not opened.

(In reply to Michael from comment #12)

I have found a case where this bug always occurs. Using Salvattore, a library agnostic JS script, this bug always shows up when Web Console (Ctrl+Shift+K) is opened and reload a page with Salvattore javascript. I'm using Salvattore on a new website project I'm currently working on and I'm using Firefox Web Developer Tools to debug, which is how I came across this bug.

https://salvattore.js.org
https://github.com/rnmp/salvattore

User Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:82.0) Gecko/20100101 Firefox/82.0
Build ID: 20201014125134

Reproducible: Always

Steps to Reproduce:

  1. Open a website with Salvattore js, for example https://salvattore.js.org
  2. Open Web Console (Ctrl+Shift+K)
  3. Reload the page

Actual Results:
The javascript for Salvattore has stopped with error.
This message is displayed in Web Console:


Uncaught Error: Permission denied to access property "mediaText"
v https://salvattore.js.org/site.js:1
v https://salvattore.js.org/site.js:1
v https://salvattore.js.org/site.js:1
m https://salvattore.js.org/site.js:1
<anonymous> https://salvattore.js.org/site.js:1
i https://salvattore.js.org/site.js:1
b https://salvattore.js.org/site.js:1
i https://salvattore.js.org/site.js:1
b https://salvattore.js.org/site.js:1
i https://salvattore.js.org/site.js:1
s https://salvattore.js.org/site.js:1
setTimeout handler*s https://salvattore.js.org/site.js:1
<anonymous> https://salvattore.js.org/site.js:1
<anonymous> https://salvattore.js.org/site.js:1

Expected Results:
The javascript for Salvattore is executed.

You have to close Web Console and Web Developer window, then reload the page to make Salvattore javacript run normal.
This bug never occurs when Web Console and Web Developer window is not opened.

More information:
This bug with Salvattore JS (for example https://salvattore.js.org) doesn't not occur with Firefox 80.0.1.
User Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:80.0) Gecko/20100101 Firefox/80.0
Build ID: 20200831163820

(In reply to Michael from comment #12)

I have found a case where this bug always occurs. Using Salvattore, a library agnostic JS script, this bug always shows up when Web Console (Ctrl+Shift+K) is opened and reload a page with Salvattore javascript. I'm using Salvattore on a new website project I'm currently working on and I'm using Firefox Web Developer Tools to debug, which is how I came across this bug.

https://salvattore.js.org
https://github.com/rnmp/salvattore

User Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:82.0) Gecko/20100101 Firefox/82.0
Build ID: 20201014125134

Reproducible: Always

Steps to Reproduce:

  1. Open a website with Salvattore js, for example https://salvattore.js.org
  2. Open Web Console (Ctrl+Shift+K)
  3. Reload the page

Actual Results:
The javascript for Salvattore has stopped with error.
This message is displayed in Web Console:


Uncaught Error: Permission denied to access property "mediaText"
v https://salvattore.js.org/site.js:1
v https://salvattore.js.org/site.js:1
v https://salvattore.js.org/site.js:1
m https://salvattore.js.org/site.js:1
<anonymous> https://salvattore.js.org/site.js:1
i https://salvattore.js.org/site.js:1
b https://salvattore.js.org/site.js:1
i https://salvattore.js.org/site.js:1
b https://salvattore.js.org/site.js:1
i https://salvattore.js.org/site.js:1
s https://salvattore.js.org/site.js:1
setTimeout handler*s https://salvattore.js.org/site.js:1
<anonymous> https://salvattore.js.org/site.js:1
<anonymous> https://salvattore.js.org/site.js:1

Expected Results:
The javascript for Salvattore is executed.

You have to close Web Console and Web Developer window, then reload the page to make Salvattore javacript run normal.
This bug never occurs when Web Console and Web Developer window is not opened.

More information:
This bug with Salvattore JS (for example https://salvattore.js.org) doesn't not occur with Firefox 81.0.2.
User Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:81.0) Gecko/20100101 Firefox/81.0
Build ID: 20201012085804

I can repro that issue, but given it seems unrelated to comment 0 and is a regression (see there), I filed bug 1673199.

Regressed by: 1659589

(In reply to Emilio Cobos Álvarez (:emilio) from comment #15)

I can repro that issue, but given it seems unrelated to comment 0 and is a regression (see there), I filed bug 1673199.

Thank you!

No longer regressed by: 1659589

Clear a needinfo that is pending on an inactive user.

For more information, please visit auto_nag documentation.

Flags: needinfo?(ab)
Severity: normal → S3

worksforme with Nightly Fx 129.

Status: NEW → RESOLVED
Closed: 2 years ago
Resolution: --- → WORKSFORME
Whiteboard: [domcore-bugbash-triaged]
You need to log in before you can comment on or make changes to this bug.