Bug 1204268 - 'appcache validate' command doesn't work when manifest is in outer directory r=miker

MozReview-Commit-ID: Dtl5prPOQTT

--HG--
extra : rebase_source : e35884fe5877f96d8366f3d0023112be959c494b
This commit is contained in:
Michael Ratcliffe 2018-02-27 12:26:03 +00:00
Родитель 294979dc32
Коммит 0d7fac1c23
10 изменённых файлов: 48 добавлений и 17 удалений

Просмотреть файл

@ -26,7 +26,9 @@ skip-if = !e10s
support-files =
browser_cmd_appcache_valid_appcache.appcache
browser_cmd_appcache_valid_appcache.appcache^headers^
browser_cmd_appcache_valid_index.html
browser_cmd_appcache_valid_index_relative_manifest.html
browser_cmd_appcache_valid_index_root_relative_manifest.html
browser_cmd_appcache_valid_index_absolute_manifest.html
browser_cmd_appcache_valid_page1.html
browser_cmd_appcache_valid_page2.html
browser_cmd_appcache_valid_page3.html

Просмотреть файл

@ -5,7 +5,8 @@
// Tests that the appcache commands works as they should
const TEST_URI = "https://sub1.test2.example.com/browser/devtools/client/" +
"commandline/test/browser_cmd_appcache_valid_index.html";
"commandline/test/" +
"browser_cmd_appcache_valid_index_relative_manifest.html";
function test() {
return Task.spawn(spawnTest).then(finish, helpers.handleError);
@ -111,8 +112,8 @@ function* spawnTest() {
setup: "appcache validate " + TEST_URI,
check: {
input: "appcache validate " + TEST_URI,
// appcache validate https://sub1.test2.example.com/browser/devtools/client/commandline/test/browser_cmd_appcache_valid_index.html
markup: "VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV",
// appcache validate http://sub1.test2.example.com/browser/devtools/client/commandline/test/browser_cmd_appcache_valid_index_relative_manifest.html
markup: "VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV",
status: "VALID",
args: {
uri: {
@ -152,8 +153,8 @@ function* spawnTest() {
post: function (output, text) {
ok(!text.includes("index"), "index is not contained in output");
ok(!text.includes("page1"), "page1 is not contained in output");
ok(!text.includes("page2"), "page1 is not contained in output");
ok(!text.includes("page3"), "page1 is not contained in output");
ok(!text.includes("page2"), "page2 is not contained in output");
ok(!text.includes("page3"), "page3 is not contained in output");
}
},
@ -161,8 +162,8 @@ function* spawnTest() {
setup: "appcache viewentry --key " + TEST_URI,
check: {
input: "appcache viewentry --key " + TEST_URI,
// appcache viewentry --key https://sub1.test2.example.com/browser/devtools/client/commandline/test/browser_cmd_appcache_valid_index.html
markup: "VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV",
// appcache viewentry --key http://sub1.test2.example.com/browser/devtools/client/commandline/test/browser_cmd_appcache_valid_index_relative_manifest.html
markup: "VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV",
status: "VALID",
args: {}
},

Просмотреть файл

@ -1,5 +1,5 @@
CACHE MANIFEST
browser_cmd_appcache_valid_index.html
browser_cmd_appcache_valid_index_relative_manifest.html
browser_cmd_appcache_valid_page1.html
browser_cmd_appcache_valid_page2.html
browser_cmd_appcache_valid_page3.html

Просмотреть файл

@ -0,0 +1,13 @@
<!DOCTYPE html>
<html manifest="http://sub1.test2.example.com/browser/devtools/client/commandline/test/browser_cmd_appcache_valid_appcache.appcache">
<head>
<meta charset="UTF-8">
<head>
<body>
<h1>Example index.html</h1>
<a href="browser_cmd_appcache_valid_index_absolute_manifest.html">Home</a> |
<a href="browser_cmd_appcache_valid_page1.html">Page 1</a> |
<a href="browser_cmd_appcache_valid_page2.html">Page 2</a> |
<a href="browser_cmd_appcache_valid_page3.html">Page 3</a>
</body>
</html>

Просмотреть файл

@ -5,7 +5,7 @@
<head>
<body>
<h1>Example index.html</h1>
<a href="browser_cmd_appcache_valid_index.html">Home</a> |
<a href="browser_cmd_appcache_valid_index_relative_manifest.html">Home</a> |
<a href="browser_cmd_appcache_valid_page1.html">Page 1</a> |
<a href="browser_cmd_appcache_valid_page2.html">Page 2</a> |
<a href="browser_cmd_appcache_valid_page3.html">Page 3</a>

Просмотреть файл

@ -0,0 +1,13 @@
<!DOCTYPE html>
<html manifest="/browser/devtools/client/commandline/test/browser_cmd_appcache_valid_appcache.appcache">
<head>
<meta charset="UTF-8">
<head>
<body>
<h1>Example index.html</h1>
<a href="browser_cmd_appcache_valid_index_root_relative_manifest.html">Home</a> |
<a href="browser_cmd_appcache_valid_page1.html">Page 1</a> |
<a href="browser_cmd_appcache_valid_page2.html">Page 2</a> |
<a href="browser_cmd_appcache_valid_page3.html">Page 3</a>
</body>
</html>

Просмотреть файл

@ -5,7 +5,7 @@
<head>
<body>
<h1>Example page1.html</h1>
<a href="browser_cmd_appcache_valid_index.html">Home</a> |
<a href="browser_cmd_appcache_valid_index_relative_manifest.html">Home</a> |
<a href="browser_cmd_appcache_valid_page1.html">Page 1</a> |
<a href="browser_cmd_appcache_valid_page2.html">Page 2</a> |
<a href="browser_cmd_appcache_valid_page3.html">Page 3</a>

Просмотреть файл

@ -5,7 +5,7 @@
<head>
<body>
<h1>Example page2.html</h1>
<a href="browser_cmd_appcache_valid_index.html">Home</a> |
<a href="browser_cmd_appcache_valid_index_relative_manifest.html">Home</a> |
<a href="browser_cmd_appcache_valid_page1.html">Page 1</a> |
<a href="browser_cmd_appcache_valid_page2.html">Page 2</a> |
<a href="browser_cmd_appcache_valid_page3.html">Page 3</a>

Просмотреть файл

@ -5,7 +5,7 @@
<head>
<body>
<h1>Example page3.html</h1>
<a href="browser_cmd_appcache_valid_index.html">Home</a> |
<a href="browser_cmd_appcache_valid_index_relative_manifest.html">Home</a> |
<a href="browser_cmd_appcache_valid_page1.html">Page 1</a> |
<a href="browser_cmd_appcache_valid_page2.html">Page 2</a> |
<a href="browser_cmd_appcache_valid_page3.html">Page 3</a>

Просмотреть файл

@ -312,14 +312,16 @@ AppCacheUtils.prototype = {
let htmlNode = this.doc.querySelector("html[manifest]");
if (htmlNode) {
let pageUri = this.doc.location ? this.doc.location.href : this.uri;
let origin = pageUri.substr(0, pageUri.lastIndexOf("/") + 1);
let manifestURI = htmlNode.getAttribute("manifest");
if (manifestURI.startsWith("/")) {
manifestURI = manifestURI.substr(1);
let originRegExp = new RegExp(/([a-z]*:\/\/[^/]*\/)/);
if (originRegExp.test(manifestURI)) {
return manifestURI;
} else if (manifestURI.startsWith("/")) {
return pageUri.match(originRegExp)[0] + manifestURI.substring(1);
}
return origin + manifestURI;
return pageUri.substring(0, pageUri.lastIndexOf("/") + 1) + manifestURI;
}
};