New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 632823 link

Starred by 7 users

Issue metadata

Status: Fixed
Owner:
Closed: Oct 2016
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: All
Pri: 1
Type: Compat



Sign in to add a comment

Service Worker still runs when JS is disabled

Reported by n...@medium.com, Jul 29 2016

Issue description

UserAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36

Example URL:

Steps to reproduce the problem:
1. Go to a website with a Service Worker, so that the service worker is installed
2. Go to settings and disable JavaScript
3. Visit the site again

What is the expected behavior?
JavaScript is disabled, so the service worker should not run

What went wrong?
The Service Worker runs anyway

Does it occur on multiple sites: N/A

Is it a problem with a plugin? N/A 

Did this work before? N/A 

Does this work in other browsers? Yes 

Chrome version: 51.0.2704.103  Channel: n/a
OS Version: OS X 10.11.5
Flash Version: Shockwave Flash 22.0 r0

This works correctly in Firefox

This puts the user in a bad, wedged state: the service worker is still running, and we can't turn it off because we need JS to turn it off.
 
Labels: Needs-Bisect
Could you please any sample webpages/testcases?

Comment 2 by n...@medium.com, Jul 29 2016

https://googlechrome.github.io/samples/service-worker/mock-responses/index.html

Notice that if you visit the page, then disable js, then revisit it, you will see console logs from the serviceworker running
Cc: tkonch...@chromium.org
Labels: Needs-Feedback
Tested the same on mac 10.11.5 chrome version 52.0.2743.82 and canary 54.0.2814.0 - Observed that console logs show that the service worker is running - Please find the screenshot

But the same is observed in Firefox as well- screenshot attached

Could you please test the same in other browsers and update the thread with your observations.
Screen Shot 2016-08-01 at 2.14.35 PM.png
869 KB View Download
Screen Shot 2016-08-01 at 2.12.22 PM.png
981 KB View Download
Components: Blink>ServiceWorker
Labels: -Needs-Bisect
Removing from bisect queue since the issue is not reproducible as per #3.

nick@ Are you still seeing the same issue in latest chrome Stable-52.0.2743.116?

Comment 6 by n...@medium.com, Aug 10 2016

yes, i'm still able to reproduce the problem at 52.0.2743.116
Cc: horo@chromium.org
Labels: -OS-Mac OS-All
Status: Available (was: Unconfirmed)
I could confirm this could be reproduced. I guess the disable-javascript flag should be checked before the request is handled by SW. 

horo-san, do you know anything about the flag?
Scripts in usual documents are restricted at https://cs.chromium.org/chromium/src/third_party/WebKit/Source/bindings/core/v8/ScriptController.cpp?rcl=1470626560&l=313, but SW uses WorkerOrWorkletScriptController instead of ScriptController which doesn't have the check. I think we have to add it somehow.

Comment 9 by falken@chromium.org, Aug 10 2016

This is a duplicate of  Issue 606959  but comes to a different conclusion than that issue. So I'll let whoever takes this issue work out how to merge the two bugs.

Comment 10 by n...@medium.com, Aug 10 2016

That issue seems like it reaches the same conclusion, not sure what part you think it's different? I would be fine with de-duping this against that bug.

Comment 11 by addyo@chromium.org, Aug 10 2016

Labels: Hotlist-DevRel
Ran into this a few times building PWAs. I'd personally favor doing a check for JS being disabled before handing off to SW (it does still start per 606959), however there may be good reasons for that not being feasible. 
Cc: falken@chromium.org jakearchibald@chromium.org slightlyoff@chromium.org kenjibaheux@chromium.org
 Issue 606959  has been merged into this issue.
Labels: -Pri-2 Pri-3
Owner: shimazu@chromium.org
Status: Assigned (was: Available)
It's easier way not to launch the SW when the disabling flags is on, but, if my understanding is correct, when the flag gets turned on after launching, the SW script will handle requests though JS is disabled.
I think it's better to disable to execute JS than disable to start SW.

I'll take over this issue from falken@.

# Anyway, why is this Hotlist-DevRel? I guess SW can be disabled by using "Bypass for network". Should I keep this issue higher priority?

Comment 14 by n...@medium.com, Aug 12 2016

Here's a better example of why I think the service workers should be disabled when JS is disabled:
https://github.com/GoogleChrome/application-shell (Demo: https://app-shell.appspot.com/)

DevRel has been encouraging a PWA architecture where the service worker loads a "shell", and then JS in the shell loads the content.

In the demo, if you have JS disabled and no service worker, the page loads OK.

If you have JS disabled and a service worker installed, the service worker serves a broken shell.
Labels: -Pri-3 M-55 Pri-1
Status: Started (was: Assigned)
I'm asking how to check the settings of disabling JS at https://cs.chromium.org/chromium/src/chrome/browser/chrome_content_browser_client.cc?sq=package:chromium&rcl=1474946434&l=1764 .
Now I'm working at https://crrev.com/2377603002, and I'm thinking how to set an icon to indicate javascripts are disabled.
Project Member

Comment 18 by bugdroid1@chromium.org, Oct 6 2016

Status: Fixed (was: Started)
Cc: ranjitkan@chromium.org
Labels: ne
Recheck this on Chrome Version 55.0.2883.5 on Windows 10, MAC 10.11.6, Ubuntu 14.04. Followed the below steps:

1) Installed chrome and navigated to the test URL provided in Comment#2
2) Navigated to Dev tools and observe that Service workers are displayed in console (Attachment - Service Worker - Java Script Enabled.png)
3) Disabled javaScript from Dev tools>Settings
4) Reloaded the Test URL.
5) In console observed that Only a single event was displayed in Console Log (Attachment - Service Worker  - Java Script Disabled.png)

@shimazu: Request you to please check the attached screen shots if this is the expected behavior.

Thanks.!
Service Worker - Java Script Enabled.png
443 KB View Download
Service Worker - Java Script Disabled.png
293 KB View Download
Labels: -ne
Components: Platform>DevTools>JavaScript
Status: Started (was: Fixed)
I can repro it. It works fine if JS is disabled from chrome://settings/content, but it doesn't from DevTools. 

DevTools folks: is there any kind of difference between the two?
Since this is mostly fixed in M55 (good work!), can we close this one and open a new bug to track the remaining work of honoring the DevTools setting? (IMO from a privacy perspective the user setting is more important and the P1)

shimazu: Also I'd recommend to CC someone directly with your question.
Status: Fixed (was: Started)
Sounds good. I created another issue ( Issue 656516 ).

> shimazu: Also I'd recommend to CC someone directly with your question.
I'll do it next time, thanks:)
Project Member

Comment 25 by bugdroid1@chromium.org, Oct 27 2016

Labels: merge-merged-2840
The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/ce8af8812b8de0246975c932063b1e03ed570068

commit ce8af8812b8de0246975c932063b1e03ed570068
Author: shimazu <shimazu@chromium.org>
Date: Thu Oct 06 23:49:21 2016

Disable ServiceWorker when JS is disabled

This patch restricts the service worker when JavaScript is disabled by checking
the settings in ChromeContentBrowserClient::AllowServiceWorker().

BUG= 632823 

Review-Url: https://codereview.chromium.org/2377603002
Cr-Commit-Position: refs/heads/master@{#423745}

[modify] https://crrev.com/ce8af8812b8de0246975c932063b1e03ed570068/chrome/browser/chrome_content_browser_client.cc
[modify] https://crrev.com/ce8af8812b8de0246975c932063b1e03ed570068/chrome/browser/chrome_service_worker_browsertest.cc
[modify] https://crrev.com/ce8af8812b8de0246975c932063b1e03ed570068/chrome/browser/content_settings/tab_specific_content_settings.cc
[modify] https://crrev.com/ce8af8812b8de0246975c932063b1e03ed570068/chrome/browser/content_settings/tab_specific_content_settings.h
[modify] https://crrev.com/ce8af8812b8de0246975c932063b1e03ed570068/chrome/browser/content_settings/tab_specific_content_settings_unittest.cc
[modify] https://crrev.com/ce8af8812b8de0246975c932063b1e03ed570068/chrome/browser/ui/content_settings/content_setting_bubble_model_unittest.cc
[modify] https://crrev.com/ce8af8812b8de0246975c932063b1e03ed570068/content/browser/service_worker/service_worker_dispatcher_host.cc

Comment 26 by dimu@google.com, Nov 4 2016

Labels: -merge-merged-2840
[Automated comment] removing mislabelled merge-merged-2840

Sign in to add a comment