Closed Bug 1757457 Opened 2 years ago Closed 1 year ago

"disable javascript" not working anymore

Categories

(DevTools :: Debugger, defect, P2)

Firefox 97
defect

Tracking

(firefox112 fixed)

RESOLVED FIXED
112 Branch
Tracking Status
firefox112 --- fixed

People

(Reporter: thetetet, Assigned: jdescottes, NeedInfo)

References

(Blocks 2 open bugs)

Details

Attachments

(2 files)

User Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:97.0) Gecko/20100101 Firefox/97.0

Steps to reproduce:

in the developer toolbar settings, section "advanced settings" there is a setting "disable javascript".
This used to work until recently but not anymore.

Actual results:

I disabled javascript, page was reloaded but javascript was still active.

Expected results:

javascript execution should have been disabled.

The Bugbug bot thinks this bug should belong to the 'Firefox::Preferences' component, and is moving the bug to that component. Please revert this change in case you think the bot is wrong.

Component: Untriaged → Preferences
Component: Preferences → General
Product: Firefox → DevTools

Hello! I have tried to reproduce the issue with firefox 99.0a1(2022-03-01), 97.0.1 and 98.0 under Ubuntu 20.04 but unfortunately I wasn't able to reproduce the issue.
Could you answer the following questions in order to further investigate this issue.

  1. Does this issue happen with a new profile? Here is a link on how to create one: https://support.mozilla.org/en-US/kb/profile-manager-create-remove-switch-firefox-profiles
  2. Does this issue happen in the latest nightly? Here is a link from where you can download it: https://www.mozilla.org/en-US/firefox/channel/desktop/
  3. Do you have any addons installed if so can you list them?
Flags: needinfo?(thetetet)

Navigating away from inspected page enables JavaScript but Developer Tools setting still show "Disable JavaScript" turned on

I've hit scenario when Developer Toolbox shows disabled JS whilst inspected page actually executes scripts. Disabling JS in the toolbox works until you navigate to other page in the same tab. (My wild guess is that HTTP redirect might do this as well (?)).

STR:

  1. Open new tab.
  2. Open devtools (F12 key), Preferences (F1 key), Check "Disable JavaScript" setting.
  3. Navigate to:
    data:text/html,JavaScript is: <script>document.write('enabled')</script><noscript>disabled</noscript> 1
    Observation: page reads "JavaScript is: enabled 1".
    Expected: "JavaScript is: disabled 1".
  4. Un-check and re-check "Disable JavaScript" setting.
    Observation: page reads "JavaScript is: disabled 1" (correct).
  5. Change 1 to 2 at the end of the URL and navigate.
    Observation: page reads "JavaScript is: enabled 2".
    Expected: "JavaScript is: disabled 2".

The only way to get "JavaScript is: disabled 2" without re-checking the devtools checkbox is quite strange as well; for me it is:

  1. navigate back to page 1 (alt + left arrow),
  2. then forth to page 2 (alt + right arrow),
  3. refresh the page (f5).
    Refreshing the page without navigating back and forth had no effect.

Redirect a needinfo that is pending on an inactive user to the triage owner.
:Honza, since the bug has recent activity, could you have a look please?

For more information, please visit auto_nag documentation.

Flags: needinfo?(thetetet) → needinfo?(odvarko)

Thank you for the STRs!

I can reproduce this on my machine (Win11, Firefox Nightly)

Honza

Status: UNCONFIRMED → NEW
Component: General → Debugger
Ever confirmed: true
Flags: needinfo?(odvarko)
Whiteboard: [devtools-triage]

Here's a video reproduction of the issue in Firefox 108 on MacOS 11.7.1
https://home.tophil.com/share/FirefoxDisabledJSRepro.mov

Codepen 1: https://codepen.io/philiprenich/pen/NWBpVKo
Codepen 2: https://codepen.io/philiprenich/pen/yLqMWyB

  • In the video I load #1 with JS enabled. The content is replaced. I then disable JS, the page is refreshed and the content is not replaced (JS does not run.
  • Then I use the link to navigate to #2. The content is replaced even though I'm on the same domain and the Disable JS is still ticked.
  • Navigating to the original page (through a link) to #1 and JS was run and content replaced.

Both #2 and the re-navigate to #1 should have JS disabled.

We seem to have the following issues:

  • disable javascript does not persist after navigation
  • disable javascript is not restored properly in case of a BF cache navigation (if you go back to a browsing context which had js disabled, you will still have it disabled even if you reenabled it in devtools settings)

Need to check if those are the same issue, add tests and fix this.

Severity: -- → S3
Flags: needinfo?(jdescottes)
Priority: -- → P2
See Also: → 1758376
Flags: needinfo?(jdescottes)
Whiteboard: [devtools-triage]
Duplicate of this bug: 1758376

:jdescottes / Julian (sorry not sure how mentions work here!),
Can you clarify the feature intention? If a user disables JavaScript on Site A and navigates by any means to Site B (link, directly entering url) should JavaScript remain disabled? That is, should JavaScript be disabled until the user turns it back on explicitly? While the browser session exists? While dev tools is open? I’m a little unsure what the intention is. Personally I expect it to remain off until I turn it on, or at least while the browser session or devtools remain active.
Thanks, and glad to see this getting some traction 🙏🏼

I’m a little unsure what the intention is

I think that javascript should remain disabled across navigations, as long as the DevTools remain open on the tab. Nothing in the feature indicates that this feature only impacts a single page. "Current session only" is indeed a bit weird, and I can't tell if this is meant to refer to the current DevTools session (that's what I assume) or if it was something different.

Once I have a better understanding of how this feature was intended to work I'll report back here. But unless there are strong technical limitations, I think this setting should apply across navigation as long DevTools remain open or until the user explicitly turns it off.

This setting should also not be preserved when restarting DevTools or the Browser. Basically when you open DevTools it should never automatically disable JavaScript. It makes it a bit weird to represent that with a checkbox in our settings panel, but I think doing the opposite would make it hard to use.

:jdescottes / Julian (sorry not sure how mentions work here!),

If you want to ping someone in particular, you can use the "Request information from" under the comment box.

Flags: needinfo?(jdescottes)

I’m a little unsure what the intention is

I think this setting should apply across navigation as long DevTools remain open or until the user explicitly turns it off.

Yes, it is explained like that in the "hover" title tooltip of that option:

Turning this option on will disable JavaScript for the current tab.
If the tab or the toolbox is closed then this setting will be forgotten.

I've always understood this like this should effectively flip javascript.enabled about:config pref for the tab (with all its subframes) that toolbox is attached to, as long as the toolbox is opened.

I agree to your point on navigations in the same tab/window.
(In reply to Julian Descottes [:jdescottes] from comment #10)

I think that javascript should remain disabled across navigations, as long as the DevTools remain open on the tab. Nothing in the feature indicates that this feature only impacts a single page. <...>

This makes it possible to disable Javascript on an unrelated page and navigate to a page that needs the script execution to be prevented from the start (not a reload).

This setting should also not be preserved when restarting DevTools or the Browser. Basically when you open DevTools it should never automatically disable JavaScript. It makes it a bit weird to represent that with a checkbox in our settings panel, but I think doing the opposite would make it hard to use.

Yes, it would cause a hindrance and an obvious mess of preferences that might be forgotten about and a cause of more confusing, -maybe caused by user- bug reports. Though I would kind of like a 'slam on the brakes' way to enter the debugger.. That might be a new, specific, entry-point to the toolbox?

I can see that after navigation, allowJavascript is correctly set for the browsing context, but it seems we need to call
RecomputeCanExecuteScripts() to force it to be applied to the new page. Not sure if doing this here makes sense or if it should be done earlier.

Also there are still other issues with this feature:

  • closing the toolbox does not reload the page: meaning JavaScript remains disabled on the page
  • similarly all pages which have been put in bfcache will retain the javascript disabled/enabled setting

For the first issue, I wonder if we should force a reload when closing the toolbox (iff javascript disabled was toggled).
And for the second issue, could we invalidate contexts put in bfcache for a given browsing context when we toggle allowJavaScript?

Olli: Does this change make sense at least to fix the basic issue?

Assignee: nobody → jdescottes
Status: NEW → ASSIGNED
Blocks: 1816243
Blocks: 1816422
Pushed by jdescottes@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/c3fdc6c386d7
[devtools] Recompute mCanExecuteScripts after navigation r=smaug
Status: ASSIGNED → RESOLVED
Closed: 1 year ago
Resolution: --- → FIXED
Target Milestone: --- → 112 Branch
Regressions: 1816691
Regressions: 1816898
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: