mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-25 11:58:55 +00:00
Backed out 6 changesets (bug 1456995) for devtools failure at browser/browser_aboutdebugging_serviceworker_timeout.js. On a CLOSED TREE
Backed out changeset 2237ceb903a4 (bug 1456995) Backed out changeset 5ce169fa82fb (bug 1456995) Backed out changeset e64553b959f9 (bug 1456995) Backed out changeset 7c53d7ca5ef7 (bug 1456995) Backed out changeset 67e23c511201 (bug 1456995) Backed out changeset e127b732bab0 (bug 1456995)
This commit is contained in:
parent
3d718557fc
commit
1a37376531
@ -95,6 +95,7 @@ InternalRequest::InternalRequest(const nsACString& aURL,
|
||||
mResponseTainting(LoadTainting::Basic),
|
||||
mCacheMode(RequestCache::Default),
|
||||
mRedirectMode(RequestRedirect::Follow),
|
||||
mMozErrors(false),
|
||||
mAuthenticationFlag(false),
|
||||
mPreserveContentCodings(false)
|
||||
// FIXME(nsm): This should be false by default, but will lead to the
|
||||
@ -130,6 +131,7 @@ InternalRequest::InternalRequest(
|
||||
mCacheMode(aCacheMode),
|
||||
mRedirectMode(aRequestRedirect),
|
||||
mIntegrity(aIntegrity),
|
||||
mMozErrors(false),
|
||||
mAuthenticationFlag(false),
|
||||
mPreserveContentCodings(false)
|
||||
// FIXME See the above comment in the default constructor.
|
||||
|
@ -406,7 +406,7 @@ class InternalRequest final {
|
||||
RequestCache mCacheMode;
|
||||
RequestRedirect mRedirectMode;
|
||||
nsString mIntegrity;
|
||||
bool mMozErrors = false;
|
||||
bool mMozErrors;
|
||||
nsCString mFragment;
|
||||
MOZ_INIT_OUTSIDE_CTOR bool mAuthenticationFlag;
|
||||
MOZ_INIT_OUTSIDE_CTOR bool mPreserveContentCodings;
|
||||
|
@ -486,27 +486,26 @@ void ServiceWorkerManager::MaybeStartShutdown() {
|
||||
|
||||
mShuttingDown = true;
|
||||
|
||||
for (auto& entry : mRegistrationInfos) {
|
||||
auto& dataPtr = entry.GetData();
|
||||
|
||||
for (auto& timerEntry : dataPtr->mUpdateTimers) {
|
||||
timerEntry.GetData()->Cancel();
|
||||
for (auto it1 = mRegistrationInfos.Iter(); !it1.Done(); it1.Next()) {
|
||||
for (auto it2 = it1.UserData()->mUpdateTimers.Iter(); !it2.Done();
|
||||
it2.Next()) {
|
||||
nsCOMPtr<nsITimer> timer = it2.UserData();
|
||||
timer->Cancel();
|
||||
}
|
||||
dataPtr->mUpdateTimers.Clear();
|
||||
it1.UserData()->mUpdateTimers.Clear();
|
||||
|
||||
for (auto& queueEntry : dataPtr->mJobQueues) {
|
||||
queueEntry.GetData()->CancelAll();
|
||||
for (auto it2 = it1.UserData()->mJobQueues.Iter(); !it2.Done();
|
||||
it2.Next()) {
|
||||
RefPtr<ServiceWorkerJobQueue> queue = it2.UserData();
|
||||
queue->CancelAll();
|
||||
}
|
||||
dataPtr->mJobQueues.Clear();
|
||||
it1.UserData()->mJobQueues.Clear();
|
||||
|
||||
for (auto& registrationEntry : dataPtr->mInfos) {
|
||||
registrationEntry.GetData()->ShutdownWorkers();
|
||||
for (auto it2 = it1.UserData()->mInfos.Iter(); !it2.Done(); it2.Next()) {
|
||||
RefPtr<ServiceWorkerRegistrationInfo> regInfo = it2.UserData();
|
||||
regInfo->ShutdownWorkers();
|
||||
}
|
||||
dataPtr->mInfos.Clear();
|
||||
}
|
||||
|
||||
for (auto& entry : mControlledClients) {
|
||||
entry.GetData()->mRegistrationInfo->ShutdownWorkers();
|
||||
it1.UserData()->mInfos.Clear();
|
||||
}
|
||||
|
||||
if (mShutdownBlocker) {
|
||||
|
@ -92,6 +92,32 @@ class ServiceWorkerManager final : public nsIServiceWorkerManager,
|
||||
NS_DECL_NSISERVICEWORKERMANAGER
|
||||
NS_DECL_NSIOBSERVER
|
||||
|
||||
struct RegistrationDataPerPrincipal;
|
||||
nsClassHashtable<nsCStringHashKey, RegistrationDataPerPrincipal>
|
||||
mRegistrationInfos;
|
||||
|
||||
struct ControlledClientData {
|
||||
RefPtr<ClientHandle> mClientHandle;
|
||||
RefPtr<ServiceWorkerRegistrationInfo> mRegistrationInfo;
|
||||
|
||||
ControlledClientData(ClientHandle* aClientHandle,
|
||||
ServiceWorkerRegistrationInfo* aRegistrationInfo)
|
||||
: mClientHandle(aClientHandle), mRegistrationInfo(aRegistrationInfo) {}
|
||||
};
|
||||
|
||||
nsClassHashtable<nsIDHashKey, ControlledClientData> mControlledClients;
|
||||
|
||||
struct PendingReadyData {
|
||||
RefPtr<ClientHandle> mClientHandle;
|
||||
RefPtr<ServiceWorkerRegistrationPromise::Private> mPromise;
|
||||
|
||||
explicit PendingReadyData(ClientHandle* aClientHandle)
|
||||
: mClientHandle(aClientHandle),
|
||||
mPromise(new ServiceWorkerRegistrationPromise::Private(__func__)) {}
|
||||
};
|
||||
|
||||
nsTArray<UniquePtr<PendingReadyData>> mPendingReadyList;
|
||||
|
||||
bool IsAvailable(nsIPrincipal* aPrincipal, nsIURI* aURI);
|
||||
|
||||
// Return true if the given content process could potentially be executing
|
||||
@ -230,6 +256,11 @@ class ServiceWorkerManager final : public nsIServiceWorkerManager,
|
||||
void LoadRegistrations(
|
||||
const nsTArray<ServiceWorkerRegistrationData>& aRegistrations);
|
||||
|
||||
// Used by remove() and removeAll() when clearing history.
|
||||
// MUST ONLY BE CALLED FROM UnregisterIfMatchesHost!
|
||||
void ForceUnregister(RegistrationDataPerPrincipal* aRegistrationData,
|
||||
ServiceWorkerRegistrationInfo* aRegistration);
|
||||
|
||||
void MaybeCheckNavigationUpdate(const ClientInfo& aClientInfo);
|
||||
|
||||
nsresult SendPushEvent(const nsACString& aOriginAttributes,
|
||||
@ -257,13 +288,6 @@ class ServiceWorkerManager final : public nsIServiceWorkerManager,
|
||||
ServiceWorkerRegistrationInfo** aRegistrationInfo);
|
||||
|
||||
private:
|
||||
struct RegistrationDataPerPrincipal;
|
||||
|
||||
static bool FindScopeForPath(const nsACString& aScopeKey,
|
||||
const nsACString& aPath,
|
||||
RegistrationDataPerPrincipal** aData,
|
||||
nsACString& aMatch);
|
||||
|
||||
ServiceWorkerManager();
|
||||
~ServiceWorkerManager();
|
||||
|
||||
@ -318,6 +342,11 @@ class ServiceWorkerManager final : public nsIServiceWorkerManager,
|
||||
static void AddScopeAndRegistration(
|
||||
const nsACString& aScope, ServiceWorkerRegistrationInfo* aRegistation);
|
||||
|
||||
static bool FindScopeForPath(const nsACString& aScopeKey,
|
||||
const nsACString& aPath,
|
||||
RegistrationDataPerPrincipal** aData,
|
||||
nsACString& aMatch);
|
||||
|
||||
static bool HasScope(nsIPrincipal* aPrincipal, const nsACString& aScope);
|
||||
|
||||
static void RemoveScopeAndRegistration(
|
||||
@ -360,37 +389,7 @@ class ServiceWorkerManager final : public nsIServiceWorkerManager,
|
||||
const nsAString& aData,
|
||||
const nsAString& aBehavior);
|
||||
|
||||
// Used by remove() and removeAll() when clearing history.
|
||||
// MUST ONLY BE CALLED FROM UnregisterIfMatchesHost!
|
||||
void ForceUnregister(RegistrationDataPerPrincipal* aRegistrationData,
|
||||
ServiceWorkerRegistrationInfo* aRegistration);
|
||||
|
||||
RefPtr<ServiceWorkerShutdownBlocker> mShutdownBlocker;
|
||||
|
||||
nsClassHashtable<nsCStringHashKey, RegistrationDataPerPrincipal>
|
||||
mRegistrationInfos;
|
||||
|
||||
struct ControlledClientData {
|
||||
RefPtr<ClientHandle> mClientHandle;
|
||||
RefPtr<ServiceWorkerRegistrationInfo> mRegistrationInfo;
|
||||
|
||||
ControlledClientData(ClientHandle* aClientHandle,
|
||||
ServiceWorkerRegistrationInfo* aRegistrationInfo)
|
||||
: mClientHandle(aClientHandle), mRegistrationInfo(aRegistrationInfo) {}
|
||||
};
|
||||
|
||||
nsClassHashtable<nsIDHashKey, ControlledClientData> mControlledClients;
|
||||
|
||||
struct PendingReadyData {
|
||||
RefPtr<ClientHandle> mClientHandle;
|
||||
RefPtr<ServiceWorkerRegistrationPromise::Private> mPromise;
|
||||
|
||||
explicit PendingReadyData(ClientHandle* aClientHandle)
|
||||
: mClientHandle(aClientHandle),
|
||||
mPromise(new ServiceWorkerRegistrationPromise::Private(__func__)) {}
|
||||
};
|
||||
|
||||
nsTArray<UniquePtr<PendingReadyData>> mPendingReadyList;
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
|
@ -11,11 +11,9 @@ const crossHelloDoc = CROSS_URI + "hello.html";
|
||||
|
||||
const sw = BASE_URI + "fetch.js";
|
||||
|
||||
const isParentInterceptEnabled = Cc["@mozilla.org/serviceworkers/manager;1"]
|
||||
.getService(Ci.nsIServiceWorkerManager)
|
||||
.isParentInterceptEnabled();
|
||||
|
||||
async function checkObserver(aInput) {
|
||||
// XXXtt: We should be able to move this check to chrome process after we move
|
||||
// the interception logic to chrome process.
|
||||
async function checkObserverInContent(aInput) {
|
||||
let interceptedChannel = null;
|
||||
|
||||
// We always get two channels which receive the "http-on-stop-request"
|
||||
@ -71,26 +69,22 @@ async function checkObserver(aInput) {
|
||||
{ start: tc.handleFetchEventStartTime, end: tc.handleFetchEventEndTime },
|
||||
];
|
||||
if (aInput.swPresent) {
|
||||
// TODO: remove this condition (but keep the if statement's body) when
|
||||
// bug 1577829 is resolved.
|
||||
if (!isParentInterceptEnabled) {
|
||||
serviceWorkerTimings.reduce((aPreviousTimings, aCurrentTimings) => {
|
||||
ok(aPreviousTimings.start !== 0, "Start time check.");
|
||||
ok(
|
||||
aPreviousTimings.start <= aCurrentTimings.start,
|
||||
"Start time order check."
|
||||
);
|
||||
ok(
|
||||
aPreviousTimings.end <= aCurrentTimings.end,
|
||||
"End time order check."
|
||||
);
|
||||
ok(
|
||||
aCurrentTimings.start <= aCurrentTimings.end,
|
||||
"Start time should be smaller than end time."
|
||||
);
|
||||
return aCurrentTimings;
|
||||
});
|
||||
}
|
||||
serviceWorkerTimings.reduce((aPreviousTimings, aCurrentTimings) => {
|
||||
ok(aPreviousTimings.start !== 0, "Start time check.");
|
||||
ok(
|
||||
aPreviousTimings.start <= aCurrentTimings.start,
|
||||
"Start time order check."
|
||||
);
|
||||
ok(
|
||||
aPreviousTimings.end <= aCurrentTimings.end,
|
||||
"End time order check."
|
||||
);
|
||||
ok(
|
||||
aCurrentTimings.start <= aCurrentTimings.end,
|
||||
"Start time should be smaller than end time."
|
||||
);
|
||||
return aCurrentTimings;
|
||||
});
|
||||
} else {
|
||||
serviceWorkerTimings.forEach(aTimings => {
|
||||
is(aTimings.start, 0, "SW timings should be 0.");
|
||||
@ -157,27 +151,6 @@ async function contentFetch(aURL) {
|
||||
await content.window.fetch(aURL);
|
||||
}
|
||||
|
||||
// The observer topics are fired in the parent process in parent-intercept
|
||||
// and the content process in child-intercept. This function will handle running
|
||||
// the check in the correct process. Note that it will block until the observers
|
||||
// are notified.
|
||||
async function fetchAndCheckObservers(
|
||||
aFetchBrowser,
|
||||
aObserverBrowser,
|
||||
aTestCase
|
||||
) {
|
||||
let promise = null;
|
||||
|
||||
if (isParentInterceptEnabled) {
|
||||
promise = checkObserver(aTestCase);
|
||||
} else {
|
||||
promise = ContentTask.spawn(aObserverBrowser, aTestCase, checkObserver);
|
||||
}
|
||||
|
||||
await ContentTask.spawn(aFetchBrowser, aTestCase.url, contentFetch);
|
||||
await promise;
|
||||
}
|
||||
|
||||
async function registerSWAndWaitForActive(aServiceWorker) {
|
||||
let swr = await content.navigator.serviceWorker.register(aServiceWorker, {
|
||||
scope: "empty.html",
|
||||
@ -195,6 +168,8 @@ async function registerSWAndWaitForActive(aServiceWorker) {
|
||||
});
|
||||
});
|
||||
|
||||
await swr.active.postMessage("claim");
|
||||
|
||||
await new Promise(resolve => {
|
||||
if (content.navigator.serviceWorker.controller) {
|
||||
return resolve();
|
||||
@ -271,19 +246,43 @@ add_task(async function test_serivce_worker_interception() {
|
||||
];
|
||||
|
||||
info("Test 1: Verify simple fetch");
|
||||
await fetchAndCheckObservers(tabBrowser, tabBrowser_observer, testcases[0]);
|
||||
let promise = ContentTask.spawn(
|
||||
tabBrowser_observer,
|
||||
testcases[0],
|
||||
checkObserverInContent
|
||||
);
|
||||
await ContentTask.spawn(tabBrowser, testcases[0].url, contentFetch);
|
||||
await promise;
|
||||
|
||||
info("Register a service worker");
|
||||
await ContentTask.spawn(tabBrowser, sw, registerSWAndWaitForActive);
|
||||
|
||||
info("Test 2: Verify simple hijack");
|
||||
await fetchAndCheckObservers(tabBrowser, tabBrowser_observer, testcases[1]);
|
||||
promise = ContentTask.spawn(
|
||||
tabBrowser_observer,
|
||||
testcases[1],
|
||||
checkObserverInContent
|
||||
);
|
||||
await ContentTask.spawn(tabBrowser, testcases[1].url, contentFetch);
|
||||
await promise;
|
||||
|
||||
info("Test 3: Verify fetch without using http cache");
|
||||
await fetchAndCheckObservers(tabBrowser, tabBrowser_observer, testcases[2]);
|
||||
promise = ContentTask.spawn(
|
||||
tabBrowser_observer,
|
||||
testcases[2],
|
||||
checkObserverInContent
|
||||
);
|
||||
await ContentTask.spawn(tabBrowser, testcases[2].url, contentFetch);
|
||||
await promise;
|
||||
|
||||
info("Test 4: make a internal redirect");
|
||||
await fetchAndCheckObservers(tabBrowser, tabBrowser_observer, testcases[3]);
|
||||
promise = ContentTask.spawn(
|
||||
tabBrowser_observer,
|
||||
testcases[3],
|
||||
checkObserverInContent
|
||||
);
|
||||
await ContentTask.spawn(tabBrowser, testcases[3].url, contentFetch);
|
||||
await promise;
|
||||
|
||||
info("Clean up");
|
||||
await ContentTask.spawn(tabBrowser, undefined, unregisterSW);
|
||||
|
@ -28,6 +28,12 @@ addEventListener("fetch", function(event) {
|
||||
}
|
||||
});
|
||||
|
||||
addEventListener("message", function(event) {
|
||||
if (event.data === "claim") {
|
||||
event.waitUntil(clients.claim());
|
||||
}
|
||||
});
|
||||
|
||||
addEventListener("activate", function(event) {
|
||||
event.waitUntil(clients.claim());
|
||||
});
|
||||
|
@ -2128,7 +2128,7 @@
|
||||
# Note, this is not currently safe to use for normal browsing yet.
|
||||
- name: dom.serviceWorkers.parent_intercept
|
||||
type: bool
|
||||
value: @IS_NIGHTLY_BUILD@
|
||||
value: false
|
||||
mirror: never
|
||||
|
||||
- name: dom.serviceWorkers.testing.enabled
|
||||
|
@ -2606,17 +2606,8 @@ toolbar#nav-bar {
|
||||
"e10s": options.e10s,
|
||||
"fission": self.extraPrefs.get('fission.autostart', False),
|
||||
"headless": options.headless,
|
||||
|
||||
# Until the test harness can understand default pref values,
|
||||
# (https://bugzilla.mozilla.org/show_bug.cgi?id=1577912) this value
|
||||
# should by synchronized with the default pref value indicated in
|
||||
# StaticPrefList.yaml.
|
||||
#
|
||||
# Currently for automation, the pref defaults to true in nightly
|
||||
# builds and false otherwise (but can be overridden with --setpref).
|
||||
"serviceworker_e10s": self.extraPrefs.get(
|
||||
'dom.serviceWorkers.parent_intercept', mozinfo.info['nightly_build']),
|
||||
|
||||
'dom.serviceWorkers.parent_intercept', False),
|
||||
"socketprocess_e10s": self.extraPrefs.get(
|
||||
'network.process.enabled', False),
|
||||
"verify": options.verify,
|
||||
|
@ -1,7 +1,7 @@
|
||||
[inside-service-worker.https.html]
|
||||
expected:
|
||||
if (os == "android") and e10s and not sw-e10s: TIMEOUT
|
||||
if (os == "android") and e10s: TIMEOUT
|
||||
[SecurityPolicyViolation event fired on global with the correct blockedURI.]
|
||||
expected:
|
||||
if (os == "android") and e10s and not sw-e10s: TIMEOUT
|
||||
if (os == "android") and e10s: TIMEOUT
|
||||
|
||||
|
@ -153,35 +153,18 @@ def env_options():
|
||||
|
||||
def run_info_extras(**kwargs):
|
||||
|
||||
def get_bool_pref_if_exists(pref):
|
||||
def get_bool_pref(pref):
|
||||
for key, value in kwargs.get('extra_prefs', []):
|
||||
if pref == key:
|
||||
return value.lower() in ('true', '1')
|
||||
return None
|
||||
|
||||
def get_bool_pref(pref):
|
||||
pref_value = get_bool_pref_if_exists(pref)
|
||||
return pref_value if pref_value is not None else False
|
||||
return False
|
||||
|
||||
rv = {"e10s": kwargs["gecko_e10s"],
|
||||
"wasm": kwargs.get("wasm", True),
|
||||
"verify": kwargs["verify"],
|
||||
"headless": kwargs.get("headless", False) or "MOZ_HEADLESS" in os.environ,
|
||||
"fission": get_bool_pref("fission.autostart")}
|
||||
|
||||
# The value of `sw-e10s` defaults to whether the "parent_intercept"
|
||||
# implementation is enabled for the current build. This value, however,
|
||||
# can be overridden by explicitly setting the pref with the `--setpref` CLI
|
||||
# flag, which is checked here. If not supplied, the default value of
|
||||
# `sw-e10s` will be filled in in `RunInfo`'s constructor.
|
||||
#
|
||||
# We can't capture the default value right now because (currently), it
|
||||
# defaults to the value of `nightly_build`, which isn't known until
|
||||
# `RunInfo`'s constructor.
|
||||
sw_e10s_override = get_bool_pref_if_exists("dom.serviceWorkers.parent_intercept")
|
||||
if sw_e10s_override is not None:
|
||||
rv["sw-e10s"] = sw_e10s_override
|
||||
|
||||
"fission": get_bool_pref("fission.autostart"),
|
||||
"sw-e10s": get_bool_pref("dom.serviceWorkers.parent_intercept")}
|
||||
rv.update(run_info_browser_version(kwargs["binary"]))
|
||||
return rv
|
||||
|
||||
|
@ -67,7 +67,8 @@ def env_extras(**kwargs):
|
||||
def run_info_extras(**kwargs):
|
||||
package = kwargs["package_name"]
|
||||
rv = {"e10s": True if package is not None and "geckoview" in package else False,
|
||||
"headless": False}
|
||||
"headless": False,
|
||||
"sw-e10s": False}
|
||||
rv.update(run_info_browser_version(kwargs["binary"]))
|
||||
return rv
|
||||
|
||||
|
@ -112,18 +112,6 @@ class RunInfo(dict):
|
||||
if extras is not None:
|
||||
self.update(extras)
|
||||
|
||||
# Until the test harness can understand default pref values,
|
||||
# (https://bugzilla.mozilla.org/show_bug.cgi?id=1577912) this value
|
||||
# should by synchronized with the default pref value indicated in
|
||||
# StaticPrefList.yaml.
|
||||
#
|
||||
# Currently for automation, the pref (and `sw-e10s`) defaults to true in
|
||||
# nightly builds and false otherwise but can be overridden with
|
||||
# `--setpref`. If overridden, the value would be initialized in
|
||||
# `run_info_extras` and be supplied in the `extras` parameter.
|
||||
if "sw-e10s" not in self:
|
||||
self["sw-e10s"] = self.get("nightly_build", False)
|
||||
|
||||
self["headless"] = extras.get("headless", False)
|
||||
self["webrender"] = enable_webrender
|
||||
|
||||
|
@ -1220,17 +1220,8 @@ class XPCShellTests(object):
|
||||
self.mozInfo = fixedInfo
|
||||
|
||||
self.mozInfo['fission'] = prefs.get('fission.autostart', False)
|
||||
|
||||
# Until the test harness can understand default pref values,
|
||||
# (https://bugzilla.mozilla.org/show_bug.cgi?id=1577912) this value
|
||||
# should by synchronized with the default pref value indicated in
|
||||
# StaticPrefList.yaml.
|
||||
#
|
||||
# Currently for automation, the pref defaults to true in nightly
|
||||
# builds and false otherwise (but can be overridden with --setpref).
|
||||
self.mozInfo['serviceworker_e10s'] = prefs.get(
|
||||
'dom.serviceWorkers.parent_intercept', self.mozInfo['nightly_build'])
|
||||
|
||||
'dom.serviceWorkers.parent_intercept', False)
|
||||
self.mozInfo['verify'] = options.get('verify', False)
|
||||
self.mozInfo['webrender'] = self.enable_webrender
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user