mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 477747 - appcache 'noupdate' event fired too early for master entries. r+sr=jst
This commit is contained in:
parent
cfb033a33d
commit
edf30b277b
@ -9,6 +9,20 @@
|
||||
|
||||
function manifestUpdated()
|
||||
{
|
||||
// Assert that we are properly associated with the application
|
||||
// cache.
|
||||
var req = new XMLHttpRequest;
|
||||
req.open("GET", "namespace2/script3.js", false);
|
||||
try {
|
||||
req.send(null);
|
||||
window.opener.OfflineTest.ok(false, "Able to fetch unlisted resource, not properly associated.");
|
||||
} catch(ex) {
|
||||
window.opener.OfflineTest.ok(true, "Unable to fetch unlisted resource, properly associated.");
|
||||
}
|
||||
|
||||
window.opener.OfflineTest.checkCache("http://localhost:8888/tests/dom/tests/mochitest/ajax/offline/updatingImplicit.html",
|
||||
true);
|
||||
|
||||
window.opener.implicitLoaded(window, false);
|
||||
}
|
||||
|
||||
|
@ -1087,6 +1087,7 @@ NS_IMPL_ISUPPORTS1(nsOfflineCacheUpdate,
|
||||
|
||||
nsOfflineCacheUpdate::nsOfflineCacheUpdate()
|
||||
: mState(STATE_UNINITIALIZED)
|
||||
, mOwner(nsnull)
|
||||
, mAddedItems(PR_FALSE)
|
||||
, mPartialUpdate(PR_FALSE)
|
||||
, mSucceeded(PR_TRUE)
|
||||
@ -1334,9 +1335,19 @@ nsOfflineCacheUpdate::LoadCompleted()
|
||||
|
||||
if (!doUpdate) {
|
||||
mSucceeded = PR_FALSE;
|
||||
NotifyNoUpdate();
|
||||
Finish();
|
||||
|
||||
for (PRInt32 i = 0; i < mDocuments.Count(); i++) {
|
||||
AssociateDocument(mDocuments[i]);
|
||||
}
|
||||
|
||||
ScheduleImplicit();
|
||||
|
||||
// If we didn't need an implicit update, we can
|
||||
// send noupdate and end the update now.
|
||||
if (!mImplicitUpdate) {
|
||||
NotifyNoUpdate();
|
||||
Finish();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1738,6 +1749,24 @@ nsOfflineCacheUpdate::AddDocument(nsIDOMDocument *aDocument)
|
||||
mDocuments.AppendObject(aDocument);
|
||||
}
|
||||
|
||||
void
|
||||
nsOfflineCacheUpdate::SetOwner(nsOfflineCacheUpdateOwner *aOwner)
|
||||
{
|
||||
NS_ASSERTION(!mOwner, "Tried to set cache update owner twice.");
|
||||
mOwner = aOwner;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsOfflineCacheUpdate::UpdateFinished(nsOfflineCacheUpdate *aUpdate)
|
||||
{
|
||||
mImplicitUpdate = nsnull;
|
||||
|
||||
NotifyNoUpdate();
|
||||
Finish();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsOfflineCacheUpdate::ScheduleImplicit()
|
||||
{
|
||||
@ -1797,9 +1826,12 @@ nsOfflineCacheUpdate::ScheduleImplicit()
|
||||
if (!added)
|
||||
return NS_OK;
|
||||
|
||||
rv = update->Schedule();
|
||||
update->SetOwner(this);
|
||||
rv = update->Begin();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
mImplicitUpdate = update;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -1833,7 +1865,7 @@ nsOfflineCacheUpdate::Finish()
|
||||
{
|
||||
LOG(("nsOfflineCacheUpdate::Finish [%p]", this));
|
||||
|
||||
// Because call to service->UpdateFinished(this) at the end of this method
|
||||
// Because the call to UpdateFinished(this) at the end of this method
|
||||
// may relese the last reference to this object but we still want to work
|
||||
// with it after Finish() call ended, make sure to release this instance in
|
||||
// the next thread loop round.
|
||||
@ -1842,12 +1874,6 @@ nsOfflineCacheUpdate::Finish()
|
||||
|
||||
mState = STATE_FINISHED;
|
||||
|
||||
nsOfflineCacheUpdateService* service =
|
||||
nsOfflineCacheUpdateService::EnsureService();
|
||||
|
||||
if (!service)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
if (!mPartialUpdate) {
|
||||
if (mSucceeded) {
|
||||
nsIArray *namespaces = mManifestItem->GetNamespaces();
|
||||
@ -1888,7 +1914,14 @@ nsOfflineCacheUpdate::Finish()
|
||||
}
|
||||
}
|
||||
|
||||
return service->UpdateFinished(this);
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
if (mOwner) {
|
||||
rv = mOwner->UpdateFinished(this);
|
||||
mOwner = nsnull;
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@ -2209,6 +2242,8 @@ nsOfflineCacheUpdateService::Schedule(nsOfflineCacheUpdate *aUpdate)
|
||||
LOG(("nsOfflineCacheUpdateService::Schedule [%p, update=%p]",
|
||||
this, aUpdate));
|
||||
|
||||
aUpdate->SetOwner(this);
|
||||
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIObserverService> observerService =
|
||||
do_GetService("@mozilla.org/observer-service;1", &rv);
|
||||
|
@ -203,7 +203,14 @@ private:
|
||||
nsCString mOldManifestHashValue;
|
||||
};
|
||||
|
||||
class nsOfflineCacheUpdateOwner
|
||||
{
|
||||
public:
|
||||
virtual nsresult UpdateFinished(nsOfflineCacheUpdate *aUpdate) = 0;
|
||||
};
|
||||
|
||||
class nsOfflineCacheUpdate : public nsIOfflineCacheUpdate
|
||||
, public nsOfflineCacheUpdateOwner
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
@ -224,6 +231,10 @@ public:
|
||||
const nsCString &aManifestHash);
|
||||
void AddDocument(nsIDOMDocument *aDocument);
|
||||
|
||||
void SetOwner(nsOfflineCacheUpdateOwner *aOwner);
|
||||
|
||||
virtual nsresult UpdateFinished(nsOfflineCacheUpdate *aUpdate);
|
||||
|
||||
private:
|
||||
nsresult HandleManifest(PRBool *aDoUpdate);
|
||||
nsresult AddURI(nsIURI *aURI, PRUint32 aItemType);
|
||||
@ -257,6 +268,8 @@ private:
|
||||
STATE_FINISHED
|
||||
} mState;
|
||||
|
||||
nsOfflineCacheUpdateOwner *mOwner;
|
||||
|
||||
PRPackedBool mAddedItems;
|
||||
PRPackedBool mPartialUpdate;
|
||||
PRPackedBool mSucceeded;
|
||||
@ -289,12 +302,15 @@ private:
|
||||
/* Reschedule count. When an update is rescheduled due to
|
||||
* mismatched manifests, the reschedule count will be increased. */
|
||||
PRUint32 mRescheduleCount;
|
||||
|
||||
nsRefPtr<nsOfflineCacheUpdate> mImplicitUpdate;
|
||||
};
|
||||
|
||||
class nsOfflineCacheUpdateService : public nsIOfflineCacheUpdateService
|
||||
, public nsIWebProgressListener
|
||||
, public nsIObserver
|
||||
, public nsSupportsWeakReference
|
||||
, public nsOfflineCacheUpdateOwner
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
@ -313,7 +329,7 @@ public:
|
||||
nsIDOMDocument *aDocument,
|
||||
nsIOfflineCacheUpdate **aUpdate);
|
||||
|
||||
nsresult UpdateFinished(nsOfflineCacheUpdate *aUpdate);
|
||||
virtual nsresult UpdateFinished(nsOfflineCacheUpdate *aUpdate);
|
||||
|
||||
/**
|
||||
* Returns the singleton nsOfflineCacheUpdateService without an addref, or
|
||||
|
Loading…
Reference in New Issue
Block a user