<!-- Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/
-->
<!DOCTYPEHTML>
<html>
<head>
<title>Bug 984048 - Test scope glob matching.</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<p id="display"></p>
<div id="content"style="display: none"></div>
<pre id="test"></pre>
<script class="testbody" type="text/javascript">
var scriptsAndScopes = [
[ "worker.js", "./sub/dir/"],
[ "worker.js", "./sub/dir" ],
[ "worker.js", "./sub/dir.html" ],
[ "worker.js", "./sub/dir/a" ],
[ "worker.js", "./sub" ],
[ "worker.js", "./star*" ], // '*' has no special meaning
];
function registerWorkers() { var registerArray = [];
scriptsAndScopes.forEach(function(item) {
registerArray.push(navigator.serviceWorker.register(item[0], { scope: item[1] }));
});
// Check register()'s step 4 which uses script's url with "./" as the scope if no scope is passed.
// The other tests already check step 5.
registerArray.push(navigator.serviceWorker.register("scope/scope_worker.js"));
// Check that SW cannot be registered for a scope "above" the script's location.
registerArray.push(new Promise(function(resolve, reject) {
navigator.serviceWorker.register("scope/scope_worker.js", { scope: "./" })
.then(function() {
ok(false, "registration scope has to be inside service worker script scope.");
reject();
}, function() {
ok(true, "registration scope has to be inside service worker script scope.");
resolve();
});
}));
return Promise.all(registerArray);
}
function unregisterWorkers() { var unregisterArray = [];
scriptsAndScopes.forEach(function(item) { var p = navigator.serviceWorker.getRegistration(item[1]);
unregisterArray.push(p.then(function(reg) {
return reg.unregister();
}));
});
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.