Closed Bug 832497 Opened 11 years ago Closed 8 years ago

Firefox don't swap cache of the applicationCache object and throws an error

Categories

(Core :: Networking: Cache, defect)

18 Branch
x86
Linux
defect
Not set
normal

Tracking

()

RESOLVED WORKSFORME

People

(Reporter: u452416, Unassigned)

Details

(Keywords: html5, js1.7)

User Agent: Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:18.0) Gecko/20100101 Firefox/18.0
Build ID: 20130107224806

Steps to reproduce:

the HTML5 applicationCache object, has the method swapCache() that is used when a new version of the manifest file is Ready to update (applicationCache.status == applicationCache.UPDATEREADY) and need to get the new file from the server.


Actual results:

The method was not executed, and I got the error:
InvalidStateError: An attempt was made to use an object that is not, or is no longer, usable


Expected results:

the browser should swap the file in the client-side by file downloaded.
Component: Untriaged → Web Apps
Keywords: html5, js1.7
Component: Web Apps → DOM: Apps
Product: Firefox → Core
Component: DOM: Apps → Networking: Cache
sjc: do you have a concrete test case we can see here (either files or a URI)?  That would be very helpful.
yes, I will make the file and put in my website. ok? Just one second, I'll adjust the file to you see the results.
I finished. You just have to allow the page to cache content in your computer clickink in allow, after you click in the test button named "Update Cache"

Here is the URI I am using to test:
http://dev.erickribeiro.com.br/moz_832497.html

The manifest file is:
http://dev.erickribeiro.com.br/manifest.appcache
In scripts used in a tutorial by Google, it shoud not throw an exception, but it does. W3 says that swapcache method do the following:
"step 4. Check that there is an application cache in the same application cache group as cache whose completeness flag is complete and that is newer than cache. If there is not, then raise an INVALID_STATE_ERR exception and abort these steps."



but it is impossible with the google code, because the method only is called when the event "updateready" is fired

(Note: The updateready event is ONLY fired when: "The resources listed in the manifest have been newly redownloaded, and the script can use swapCache() to switch to the new cache." )

here is the google code:
// Check if a new cache is available on page load.
window.addEventListener('load', function(e) {

  window.applicationCache.addEventListener('updateready', function(e) {
    if (window.applicationCache.status == window.applicationCache.UPDATEREADY) {
      // Browser downloaded a new app cache.
      // Swap it in and reload the page to get the new hotness.
      window.applicationCache.swapCache();
      if (confirm('A new version of this site is available. Load it?')) {
        window.location.reload();
      }
    } else {
      // Manifest didn't changed. Nothing new to server.
    }
  }, false);

}, false);


References:

http://www.w3.org/TR/2011/WD-html5-20110525/offline.html#dom-appcache-swapcache
http://www.w3.org/TR/2011/WD-html5-20110525/offline.html#event-appcache-updateready
I confirm that as of Firefox/24 calling applicationCache.swapCache() inside the onupdateready event causes a DOM Exception to be thrown: An attempt was made to use an object that is not, or is no longer, usable

I believe this is a dupe of 769171 ( https://bugzilla.mozilla.org/show_bug.cgi?id=769171 )
This is still occurring in FF 40. This is a critical bug.
We still see this bug in FF ESR (38.6) but not with FF 44. So this might have been fixed between these versions.
based on comment 7
Status: UNCONFIRMED → RESOLVED
Closed: 8 years ago
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.