зеркало из https://github.com/mozilla/gecko-dev.git
Merge m-c to autoland. a=merge
This commit is contained in:
Коммит
fad3aeb3a3
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -39,13 +39,21 @@ public:
|
|||
ComparisonResult(nsresult aStatus,
|
||||
bool aInCacheAndEqual,
|
||||
const nsAString& aNewCacheName,
|
||||
const nsACString& aMaxScope,
|
||||
nsLoadFlags aLoadFlags) = 0;
|
||||
const nsACString& aMaxScope) = 0;
|
||||
|
||||
/*
|
||||
* Right before fetching the main script from the network, we check whether
|
||||
* the script expiration timer has expired. Via this method, we can save the
|
||||
* result of the check, and propogate it to the new ServiceWorkerInfo if there
|
||||
* is one, so the imported scripts can be affected by the result as well.
|
||||
*/
|
||||
virtual void
|
||||
SaveLoadFlags(nsLoadFlags aLoadFlags) = 0;
|
||||
|
||||
NS_INLINE_DECL_PURE_VIRTUAL_REFCOUNTING
|
||||
};
|
||||
|
||||
void
|
||||
nsresult
|
||||
Compare(ServiceWorkerRegistrationInfo* aRegistration,
|
||||
nsIPrincipal* aPrincipal, const nsAString& aCacheName,
|
||||
const nsAString& aURL, CompareCallback* aCallback, nsILoadGroup* aLoadGroup);
|
||||
|
|
|
@ -98,14 +98,15 @@ public:
|
|||
ComparisonResult(nsresult aStatus,
|
||||
bool aInCacheAndEqual,
|
||||
const nsAString& aNewCacheName,
|
||||
const nsACString& aMaxScope,
|
||||
nsLoadFlags aLoadFlags) override
|
||||
const nsACString& aMaxScope) override
|
||||
{
|
||||
mJob->ComparisonResult(aStatus,
|
||||
aInCacheAndEqual,
|
||||
aNewCacheName,
|
||||
aMaxScope,
|
||||
aLoadFlags);
|
||||
mJob->ComparisonResult(aStatus, aInCacheAndEqual, aNewCacheName, aMaxScope);
|
||||
}
|
||||
|
||||
virtual void
|
||||
SaveLoadFlags(nsLoadFlags aLoadFlags) override
|
||||
{
|
||||
mJob->SetLoadFlags(aLoadFlags);
|
||||
}
|
||||
|
||||
NS_INLINE_DECL_REFCOUNTING(ServiceWorkerUpdateJob::CompareCallback, override)
|
||||
|
@ -317,9 +318,14 @@ ServiceWorkerUpdateJob::Update()
|
|||
|
||||
RefPtr<CompareCallback> callback = new CompareCallback(this);
|
||||
|
||||
serviceWorkerScriptCache::Compare(mRegistration, mPrincipal, cacheName,
|
||||
NS_ConvertUTF8toUTF16(mScriptSpec),
|
||||
callback, mLoadGroup);
|
||||
nsresult rv =
|
||||
serviceWorkerScriptCache::Compare(mRegistration, mPrincipal, cacheName,
|
||||
NS_ConvertUTF8toUTF16(mScriptSpec),
|
||||
callback, mLoadGroup);
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
FailUpdateJob(rv);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
nsLoadFlags
|
||||
|
@ -328,12 +334,17 @@ ServiceWorkerUpdateJob::GetLoadFlags() const
|
|||
return mLoadFlags;
|
||||
}
|
||||
|
||||
void
|
||||
ServiceWorkerUpdateJob::SetLoadFlags(nsLoadFlags aLoadFlags)
|
||||
{
|
||||
mLoadFlags = aLoadFlags;
|
||||
}
|
||||
|
||||
void
|
||||
ServiceWorkerUpdateJob::ComparisonResult(nsresult aStatus,
|
||||
bool aInCacheAndEqual,
|
||||
const nsAString& aNewCacheName,
|
||||
const nsACString& aMaxScope,
|
||||
nsLoadFlags aLoadFlags)
|
||||
const nsACString& aMaxScope)
|
||||
{
|
||||
AssertIsOnMainThread();
|
||||
|
||||
|
@ -428,7 +439,7 @@ ServiceWorkerUpdateJob::ComparisonResult(nsresult aStatus,
|
|||
mRegistration->mScope,
|
||||
mScriptSpec,
|
||||
aNewCacheName,
|
||||
aLoadFlags);
|
||||
mLoadFlags);
|
||||
|
||||
mRegistration->SetEvaluating(sw);
|
||||
|
||||
|
|
|
@ -73,6 +73,9 @@ protected:
|
|||
nsLoadFlags
|
||||
GetLoadFlags() const;
|
||||
|
||||
void
|
||||
SetLoadFlags(nsLoadFlags aLoadFlags);
|
||||
|
||||
private:
|
||||
class CompareCallback;
|
||||
class ContinueUpdateRunnable;
|
||||
|
@ -84,8 +87,7 @@ private:
|
|||
ComparisonResult(nsresult aStatus,
|
||||
bool aInCacheAndEqual,
|
||||
const nsAString& aNewCacheName,
|
||||
const nsACString& aMaxScope,
|
||||
nsLoadFlags aLoadFlags);
|
||||
const nsACString& aMaxScope);
|
||||
|
||||
// Utility method called after evaluating the worker script.
|
||||
void
|
||||
|
|
|
@ -1,23 +0,0 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
"use strict";
|
||||
|
||||
function handleRequest(request, response) {
|
||||
let count = getState("count");
|
||||
if (count === "") {
|
||||
count = "1";
|
||||
}
|
||||
|
||||
// If this is the first request, return the first source.
|
||||
if (count === "1") {
|
||||
response.setHeader("Content-Type", "application/javascript");
|
||||
response.write("// Imported.");
|
||||
setState("count", "2");
|
||||
}
|
||||
// For all subsequent requests, return the second source.
|
||||
else {
|
||||
response.setStatusLine(request.httpVersion, 404, "Not found");
|
||||
}
|
||||
}
|
||||
|
|
@ -1,33 +0,0 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
"use strict";
|
||||
|
||||
const WORKER_1 = `
|
||||
importScripts("bug1290951_worker_imported.sjs");
|
||||
`;
|
||||
|
||||
const WORKER_2 = `
|
||||
// Remove importScripts(...)" for testing purpose.
|
||||
`;
|
||||
|
||||
function handleRequest(request, response) {
|
||||
let count = getState("count");
|
||||
if (count === "") {
|
||||
count = "1";
|
||||
}
|
||||
|
||||
// This header is necessary for making this script able to be loaded.
|
||||
response.setHeader("Content-Type", "application/javascript");
|
||||
|
||||
// If this is the first request, return the first source.
|
||||
if (count === "1") {
|
||||
response.write(WORKER_1);
|
||||
setState("count", "2");
|
||||
}
|
||||
// For all subsequent requests, return the second source.
|
||||
else {
|
||||
response.write(WORKER_2);
|
||||
}
|
||||
}
|
||||
|
|
@ -215,11 +215,8 @@ support-files =
|
|||
nofetch_handler_worker.js
|
||||
service_worker.js
|
||||
service_worker_client.html
|
||||
bug1290951_worker_main.sjs
|
||||
bug1290951_worker_imported.sjs
|
||||
|
||||
[test_bug1151916.html]
|
||||
[test_bug1290951.html]
|
||||
[test_bug1240436.html]
|
||||
[test_claim.html]
|
||||
[test_claim_oninstall.html]
|
||||
|
|
|
@ -1,68 +0,0 @@
|
|||
<!--
|
||||
Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/
|
||||
-->
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Bug 1290951 - Test update after a new verion of mainscipt that doesn't need an imported script anymore.</title>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
<!--
|
||||
If the principal is not set, accessing self.caches in the worker will crash.
|
||||
-->
|
||||
</head>
|
||||
<body>
|
||||
<p id="display"></p>
|
||||
<div id="content"></div>
|
||||
<pre id="test"></pre>
|
||||
<script class="testbody" type="text/javascript">
|
||||
|
||||
// We have the iframe register for its own scope so that this page is not
|
||||
// holding any references when we GC.
|
||||
function register() {
|
||||
return Promise.resolve()
|
||||
.then(_ => navigator.serviceWorker.register("http://mochi.test:8888/" +
|
||||
"tests/dom/workers/test/" +
|
||||
"serviceworkers/" +
|
||||
"bug1290951_worker_main.sjs"))
|
||||
.then(r => ok(r, "Should be a registration."));
|
||||
}
|
||||
|
||||
function update() {
|
||||
return Promise.resolve()
|
||||
.then(_ => navigator.serviceWorker.getRegistration())
|
||||
.then(r => {
|
||||
return new Promise(aResolve => {
|
||||
r.addEventListener("updatefound", aResolve);
|
||||
r.update();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function unregister() {
|
||||
return Promise.resolve()
|
||||
.then(_ => navigator.serviceWorker.getRegistration())
|
||||
.then(r => r.unregister())
|
||||
}
|
||||
|
||||
function runTest() {
|
||||
register()
|
||||
.then(register)
|
||||
.then(update)
|
||||
.then(unregister)
|
||||
|
||||
.catch(e => ok(false, "Some test failed with error " + e))
|
||||
.then(SimpleTest.finish);
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
SpecialPowers.pushPrefEnv({"set": [
|
||||
["dom.serviceWorkers.enabled", true],
|
||||
["dom.serviceWorkers.testing.enabled", true]
|
||||
]}, runTest);
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -4626,7 +4626,7 @@ pref("network.tcp.keepalive.retry_interval", 1); // seconds
|
|||
pref("network.tcp.keepalive.probe_count", 4);
|
||||
#endif
|
||||
|
||||
pref("network.tcp.tcp_fastopen_enable", true);
|
||||
pref("network.tcp.tcp_fastopen_enable", false);
|
||||
pref("network.tcp.tcp_fastopen_consecutive_failure_limit", 5);
|
||||
|
||||
// Whether to disable acceleration for all widgets.
|
||||
|
|
|
@ -61981,16 +61981,6 @@
|
|||
{}
|
||||
]
|
||||
],
|
||||
"service-workers/service-worker/resources/bytecheck-worker-imported-script.py": [
|
||||
[
|
||||
{}
|
||||
]
|
||||
],
|
||||
"service-workers/service-worker/resources/bytecheck-worker.py": [
|
||||
[
|
||||
{}
|
||||
]
|
||||
],
|
||||
"service-workers/service-worker/resources/claim-with-redirect-iframe.html": [
|
||||
[
|
||||
{}
|
||||
|
@ -122856,12 +122846,6 @@
|
|||
{}
|
||||
]
|
||||
],
|
||||
"service-workers/service-worker/update-bytecheck.https.html": [
|
||||
[
|
||||
"/service-workers/service-worker/update-bytecheck.https.html",
|
||||
{}
|
||||
]
|
||||
],
|
||||
"service-workers/service-worker/update-recovery.https.html": [
|
||||
[
|
||||
"/service-workers/service-worker/update-recovery.https.html",
|
||||
|
@ -206425,14 +206409,6 @@
|
|||
"0ddb4f1cf84729ed673295719ec58a3e5d600a12",
|
||||
"support"
|
||||
],
|
||||
"service-workers/service-worker/resources/bytecheck-worker-imported-script.py": [
|
||||
"772d029d4efbe22f62f3473d4afe9e501a792571",
|
||||
"support"
|
||||
],
|
||||
"service-workers/service-worker/resources/bytecheck-worker.py": [
|
||||
"2693790af1dcd812bc3741db7fa355e23eef0e01",
|
||||
"support"
|
||||
],
|
||||
"service-workers/service-worker/resources/claim-with-redirect-iframe.html": [
|
||||
"fdc472f4e9a591f0b471174b2aa1783107731f49",
|
||||
"support"
|
||||
|
@ -207101,10 +207077,6 @@
|
|||
"7c8c6c3edca83d54f1838eccf3afb0b1223c7a44",
|
||||
"testharness"
|
||||
],
|
||||
"service-workers/service-worker/update-bytecheck.https.html": [
|
||||
"6562348b198124822297c6b622c3e63870427672",
|
||||
"testharness"
|
||||
],
|
||||
"service-workers/service-worker/update-recovery.https.html": [
|
||||
"aac5705d6844e4a33200418504adb57053a45be2",
|
||||
"testharness"
|
||||
|
|
|
@ -1,19 +0,0 @@
|
|||
import time
|
||||
|
||||
def main(request, response):
|
||||
headers = [('Content-Type', 'application/javascript'),
|
||||
('Cache-Control', 'max-age=0')]
|
||||
|
||||
imported_content_type = ''
|
||||
if 'imported' in request.GET:
|
||||
imported_content_type = request.GET['imported']
|
||||
|
||||
imported_content = 'default'
|
||||
if imported_content_type == 'time':
|
||||
imported_content = time.time()
|
||||
|
||||
body = '''
|
||||
// %s
|
||||
''' % (imported_content)
|
||||
|
||||
return headers, body
|
|
@ -1,28 +0,0 @@
|
|||
import time
|
||||
|
||||
def main(request, response):
|
||||
headers = [('Content-Type', 'application/javascript'),
|
||||
('Cache-Control', 'max-age=0')]
|
||||
|
||||
main_content_type = ''
|
||||
if 'main' in request.GET:
|
||||
main_content_type = request.GET['main']
|
||||
|
||||
main_content = 'default'
|
||||
if main_content_type == 'time':
|
||||
main_content = time.time()
|
||||
|
||||
imported_request_type = ''
|
||||
if 'imported' in request.GET:
|
||||
imported_request_type = request.GET['imported']
|
||||
|
||||
imported_request = ''
|
||||
if imported_request_type == 'time':
|
||||
imported_request = '?imported=time';
|
||||
|
||||
body = '''
|
||||
// %s
|
||||
importScripts('bytecheck-worker-imported-script.py%s');
|
||||
''' % (main_content, imported_request)
|
||||
|
||||
return headers, body
|
|
@ -1,127 +0,0 @@
|
|||
<!doctype html>
|
||||
<meta charset=utf-8>
|
||||
<title></title>
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="resources/testharness-helpers.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<script src="resources/test-helpers.sub.js"></script>
|
||||
<script>
|
||||
|
||||
promise_test(function(t) {
|
||||
var script = 'resources/bytecheck-worker.py' +
|
||||
'?main=default' +
|
||||
'&imported=default';
|
||||
var scope = 'resources/blank.html';
|
||||
|
||||
var swr, sw;
|
||||
return Promise.resolve()
|
||||
.then(() => service_worker_unregister_and_register(t, script, scope))
|
||||
.then(registration => swr = registration)
|
||||
|
||||
.then(() => wait_for_update(t, swr))
|
||||
.then(worker => sw = worker)
|
||||
|
||||
.then(() => wait_for_state(t, sw, 'activated'))
|
||||
.then(() => assert_array_equals([swr.active,
|
||||
swr.waiting,
|
||||
swr.installing],
|
||||
[sw,
|
||||
null,
|
||||
null]))
|
||||
|
||||
.then(() => swr.update())
|
||||
.then(() => assert_array_equals([swr.active,
|
||||
swr.waiting,
|
||||
swr.installing],
|
||||
[sw,
|
||||
null,
|
||||
null]))
|
||||
|
||||
.then(() => service_worker_unregister_and_done(t, scope));
|
||||
}, "Test with (main: same, imported: same)");
|
||||
|
||||
promise_test(function(t) {
|
||||
var script = 'resources/bytecheck-worker.py' +
|
||||
'?main=default' +
|
||||
'&imported=time';
|
||||
var scope = 'resources/blank.html';
|
||||
|
||||
var swr, sw;
|
||||
return Promise.resolve()
|
||||
.then(() => service_worker_unregister_and_register(t, script, scope))
|
||||
.then(registration => swr = registration)
|
||||
|
||||
.then(() => wait_for_update(t, swr))
|
||||
.then(worker => sw = worker)
|
||||
|
||||
.then(() => wait_for_state(t, sw, 'activated'))
|
||||
.then(() => assert_array_equals([swr.active,
|
||||
swr.waiting,
|
||||
swr.installing],
|
||||
[sw,
|
||||
null,
|
||||
null]))
|
||||
|
||||
.then(() => swr.update())
|
||||
.then(() => wait_for_update(t, swr))
|
||||
|
||||
.then(() => service_worker_unregister_and_done(t, scope));
|
||||
}, "Test with (main: same, imported: different)");
|
||||
|
||||
promise_test(function(t) {
|
||||
var script = 'resources/bytecheck-worker.py' +
|
||||
'?main=time' +
|
||||
'&imported=default';
|
||||
var scope = 'resources/blank.html';
|
||||
|
||||
var swr, sw;
|
||||
return Promise.resolve()
|
||||
.then(() => service_worker_unregister_and_register(t, script, scope))
|
||||
.then(registration => swr = registration)
|
||||
|
||||
.then(() => wait_for_update(t, swr))
|
||||
.then(worker => sw = worker)
|
||||
|
||||
.then(() => wait_for_state(t, sw, 'activated'))
|
||||
.then(() => assert_array_equals([swr.active,
|
||||
swr.waiting,
|
||||
swr.installing],
|
||||
[sw,
|
||||
null,
|
||||
null]))
|
||||
|
||||
.then(() => swr.update())
|
||||
.then(() => wait_for_update(t, swr))
|
||||
|
||||
.then(() => service_worker_unregister_and_done(t, scope));
|
||||
}, "Test with (main: different, imported: same)");
|
||||
|
||||
promise_test(function(t) {
|
||||
var script = 'resources/bytecheck-worker.py' +
|
||||
'?main=time' +
|
||||
'&imported=time';
|
||||
var scope = 'resources/blank.html';
|
||||
|
||||
var swr, sw;
|
||||
return Promise.resolve()
|
||||
.then(() => service_worker_unregister_and_register(t, script, scope))
|
||||
.then(registration => swr = registration)
|
||||
|
||||
.then(() => wait_for_update(t, swr))
|
||||
.then(worker => sw = worker)
|
||||
|
||||
.then(() => wait_for_state(t, sw, 'activated'))
|
||||
.then(() => assert_array_equals([swr.active,
|
||||
swr.waiting,
|
||||
swr.installing],
|
||||
[sw,
|
||||
null,
|
||||
null]))
|
||||
|
||||
.then(() => swr.update())
|
||||
.then(() => wait_for_update(t, swr))
|
||||
|
||||
.then(() => service_worker_unregister_and_done(t, scope));
|
||||
}, "Test with (main: different, imported: different)");
|
||||
|
||||
</script>
|
Загрузка…
Ссылка в новой задаче