Closed Bug 1180148 Opened 4 years ago Closed 4 years ago

Clear service workers registered for a site when clearing the cookies and stored data is not working in b2g

Categories

(Firefox OS Graveyard :: General, defect)

ARM
Gonk (Firefox OS)
defect
Not set

Tracking

(firefox42 fixed)

RESOLVED FIXED
FxOS-S4 (07Aug)
Tracking Status
firefox42 --- fixed

People

(Reporter: noemi, Assigned: ferjm)

References

Details

Attachments

(2 files)

STRs in b2g:
1- go to Browser and load a page that allows registering a sw that caches the page elements to be available when offline
2- go to Settings->Developer->Service Workers, the sw registered at step #1 is properly listed
2- de-activate data connection
3- go to Browser and try to reload the page. It is properly loaded (offline behavior is working as expected) 
4- go to Settings->Browsing Privacy and select "Clear cookies and stored data"
5- go to Browser and try to reload the page. It is not loaded (which is the expected behavior) but the sw is still listed under about:sw list (Settings->Developer->Service Workers)

Actual result:
The sw is listed under about:sw when cookies and stored data have been cleared

Expected result:
The sw shouldn't appear under about:sw when cookies and stored data have been cleared. It should be unregistered.


Environmental variables:
Flame device
Build Id: 2015703060349
Gecko: fbfeac8
Gaia: c2438f7
Platform version: 42.0a1

Checked on Nightly with today's (7/3) master build and it works as expected because of Bug 1080109, the sw is not listed under about:sw once cookies and stored data have been cleared. Notice that in desktop at step #4 we go to the Browser Preferences->Privacy->clear your recent history and select "clear" all the items marked by default.

It seems clearing data means something different in desktop vs b2g. Eshan, any clue about this?. Thanks!!
Flags: needinfo?(ehsan)
(In reply to Noemí Freire (:noemi) from comment #0)
> It seems clearing data means something different in desktop vs b2g.

"Clear cookies and stored data" ends up dispatching a "webapps-clear-data" notification in Gecko.  To fix this bug, you'd need to extend ServiceWorkerManager::Observe() to respond to that notification as well.  In that code, you need to be careful to read and interpret the browseronly and appId flags correctly from mozIApplicationClearPrivateDataParams.  DataStoreService::Observe() is an example of where we do this for the DataStore API.

> Eshan, any clue about this?. Thanks!!

Nit: s/Esh/Ehs/  :-)
Flags: needinfo?(ehsan)
We are already listening for "webapps-clear-data" since bug 1169249. Not sure why it is not clearing the data for non installed apps. I'll check on the next sprint.
Assignee: nobody → ferjmoreno
Target Milestone: --- → FxOS-S3 (24Jul)
Status: NEW → ASSIGNED
Attached patch v1Splinter Review
Comment on attachment 8634222 [details] [diff] [review]
v1

Andrea, could you take a look at this patch, please?

I'll be adding a marionette test on another patch. But this part should land before the marionette test because the test will be landing on Gaia and needs the Gecko part landed to pass Gaia-try.

Thanks!
Attachment #8634222 - Flags: review?(amarchesini)
Target Milestone: FxOS-S3 (24Jul) → FxOS-S4 (07Aug)
Comment on attachment 8634222 [details] [diff] [review]
v1

Review of attachment 8634222 [details] [diff] [review]:
-----------------------------------------------------------------

::: dom/workers/ServiceWorkerManager.cpp
@@ +4263,5 @@
>    char prevChar = *(--start);
>    return prevChar == '.';
>  }
>  
> +struct UnregisterIfMatchesUserData

final

::: dom/workers/ServiceWorkerManager.h
@@ +29,5 @@
>  #include "nsDataHashtable.h"
>  #include "nsRefPtrHashtable.h"
>  #include "nsTArrayForwardDeclare.h"
>  #include "nsTObserverArray.h"
> +#include "mozIApplicationClearPrivateDataParams.h"

You don't actually need this header. Forward the class name:

class mozIApplicationClearPrivateDataParams;
Attachment #8634222 - Flags: review?(amarchesini) → review+
https://hg.mozilla.org/mozilla-central/rev/b8d147ca6d04
Status: ASSIGNED → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Hi,

Just checked on m-c and it works as expected, The SW is properly unregistered. Thanks for fixing it!.

Environmental variables:
Flame device
Build Id: 20150804135250
Gecko: 57a9666
Gaia: 4e3dfb7
Platform version: 42.0a1
You need to log in before you can comment on or make changes to this bug.