Back out 7063d9f5c1fd (bug 920478) on a CLOSED TREE because a dependency was backed out

This commit is contained in:
Matt Brubeck 2013-10-17 15:32:45 -07:00
Родитель 21eb3c1a72
Коммит ce20eb66d0
10 изменённых файлов: 1 добавлений и 243 удалений

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

@ -52,7 +52,6 @@ AppValidator.prototype._getPackagedManifestURL = function () {
AppValidator.prototype._fetchManifest = function (manifestURL) {
let deferred = promise.defer();
this.manifestURL = manifestURL;
let req = new XMLHttpRequest();
try {
@ -121,68 +120,6 @@ AppValidator.prototype.validateManifest = function (manifest) {
}
}
AppValidator.prototype._getOriginURL = function (manifest) {
if (this.project.type == "packaged") {
let manifestURL = Services.io.newURI(this.manifestURL, null, null);
return Services.io.newURI(".", null, manifestURL).spec;
} else if (this.project.type == "hosted") {
return Services.io.newURI(this.project.location, null, null).prePath;
}
}
AppValidator.prototype.validateLaunchPath = function (manifest) {
let deferred = promise.defer();
// The launch_path field has to start with a `/`
if (manifest.launch_path && manifest.launch_path[0] !== "/") {
this.error(strings.formatStringFromName("validator.nonAbsoluteLaunchPath", [manifest.launch_path], 1));
deferred.resolve();
return deferred.promise;
}
let origin = this._getOriginURL();
let path;
if (this.project.type == "packaged") {
path = "." + ( manifest.launch_path || "/index.html" );
} else if (this.project.type == "hosted") {
path = manifest.launch_path || "/";
}
let indexURL;
try {
indexURL = Services.io.newURI(path, null, Services.io.newURI(origin, null, null)).spec;
} catch(e) {
this.error(strings.formatStringFromName("validator.invalidLaunchPath", [origin + path], 1));
deferred.resolve();
return deferred.promise;
}
let req = new XMLHttpRequest();
try {
req.open("HEAD", indexURL, true);
} catch(e) {
this.error(strings.formatStringFromName("validator.invalidLaunchPath", [indexURL], 1));
deferred.resolve();
return deferred.promise;
}
req.channel.loadFlags |= Ci.nsIRequest.LOAD_BYPASS_CACHE | Ci.nsIRequest.INHIBIT_CACHING;
req.onload = () => {
if (req.status >= 400)
this.error(strings.formatStringFromName("validator.invalidLaunchPathBadHttpCode", [indexURL, req.status], 2));
deferred.resolve();
};
req.onerror = () => {
this.error(strings.formatStringFromName("validator.invalidLaunchPath", [indexURL], 1));
deferred.resolve();
};
try {
req.send(null);
} catch(e) {
this.error(strings.formatStringFromName("validator.invalidLaunchPath", [indexURL], 1));
deferred.resolve();
}
return deferred.promise;
}
AppValidator.prototype.validateType = function (manifest) {
let appType = manifest.type || "web";
if (["web", "privileged", "certified"].indexOf(appType) === -1) {
@ -207,7 +144,6 @@ AppValidator.prototype.validate = function () {
this.manifest = manifest;
this.validateManifest(manifest);
this.validateType(manifest);
return this.validateLaunchPath(manifest);
}
}).bind(this));
}

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

@ -1,11 +1,8 @@
[DEFAULT]
support-files =
hosted_app.manifest
validator/*
support-files = hosted_app.manifest
[test_connection_store.html]
[test_device_store.html]
[test_projects_store.html]
[test_remain_connected.html]
[test_template.html]
[test_app_validator.html]

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

@ -1,148 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf8">
<title></title>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="chrome://mochikit/content/chrome-harness.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css">
</head>
<body>
<script type="application/javascript;version=1.8">
const Cu = Components.utils;
const Cc = Components.classes;
const Ci = Components.interfaces;
Cu.import("resource://testing-common/httpd.js");
const {devtools} = Cu.import("resource://gre/modules/devtools/Loader.jsm", {});
const {require} = devtools;
const {AppValidator} = require("devtools/app-manager/app-validator");
const {Services} = Cu.import("resource://gre/modules/Services.jsm");
const nsFile = Components.Constructor("@mozilla.org/file/local;1",
"nsILocalFile", "initWithPath");
const cr = Cc["@mozilla.org/chrome/chrome-registry;1"]
.getService(Ci.nsIChromeRegistry);
const strings = Services.strings.createBundle("chrome://browser/locale/devtools/app-manager.properties");
let httpserver, origin;
window.onload = function() {
SimpleTest.waitForExplicitFinish();
httpserver = new HttpServer();
httpserver.start(-1);
origin = "http://localhost:" + httpserver.identity.primaryPort + "/";
next();
}
function createHosted(path) {
let dirPath = getTestFilePath("validator/" + path);
httpserver.registerDirectory("/", nsFile(dirPath));
return new AppValidator({
type: "hosted",
location: origin + "/manifest.webapp"
});
}
function createPackaged(path) {
let dirPath = getTestFilePath("validator/" + path);
return new AppValidator({
type: "packaged",
location: dirPath
});
}
function next() {
let test = tests.shift();
if (test) {
try {
test();
} catch(e) {
console.error("exception", String(e), e, e.stack);
}
} else {
httpserver.stop(function() {
SimpleTest.finish();
});
}
}
let tests = [
// Test a 100% valid example
function () {
let validator = createHosted("valid");
validator.validate().then(() => {
is(validator.errors.length, 0, "valid app got no error");
is(validator.warnings.length, 0, "valid app got no warning");
next();
});
},
function () {
let validator = createPackaged("valid");
validator.validate().then(() => {
is(validator.errors.length, 0, "valid packaged app got no error");
is(validator.warnings.length, 0, "valid packaged app got no warning");
next();
});
},
// Test a launch path that returns a 404
function () {
let validator = createHosted("wrong-launch-path");
validator.validate().then(() => {
is(validator.errors.length, 1, "app with non-existant launch path got an error");
is(validator.errors[0], strings.formatStringFromName("validator.invalidLaunchPathBadHttpCode", [origin + "wrong-path.html", 404], 2),
"with the right error message");
is(validator.warnings.length, 0, "but no warning");
next();
});
},
function () {
let validator = createPackaged("wrong-launch-path");
validator.validate().then(() => {
is(validator.errors.length, 1, "app with wrong path got an error");
let file = nsFile(validator.project.location);
file.append("wrong-path.html");
let url = Services.io.newFileURI(file);
is(validator.errors[0], strings.formatStringFromName("validator.invalidLaunchPath", [url.spec], 1),
"with the expected message");
is(validator.warnings.length, 0, "but no warning");
next();
});
},
// Test when using a non-absolute path for launch_path
function () {
let validator = createHosted("non-absolute-path");
validator.validate().then(() => {
is(validator.errors.length, 1, "app with non absolute path got an error");
is(validator.errors[0], strings.formatStringFromName("validator.nonAbsoluteLaunchPath", ["non-absolute.html"], 1),
"with expected message");
is(validator.warnings.length, 0, "but no warning");
next();
});
},
function () {
let validator = createPackaged("non-absolute-path");
validator.validate().then(() => {
is(validator.errors.length, 1, "app with non absolute path got an error");
is(validator.errors[0], strings.formatStringFromName("validator.nonAbsoluteLaunchPath", ["non-absolute.html"], 1),
"with expected message");
is(validator.warnings.length, 0, "but no warning");
next();
});
},
];
</script>
</body>
</html>

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

@ -1,7 +0,0 @@
{
"name": "non-absolute path",
"icons": {
"128": "/icon.png"
},
"launch_path": "non-absolute.html"
}

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

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

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

@ -1,7 +0,0 @@
{
"name": "valid",
"launch_path": "/home.html",
"icons": {
"128": "/icon.png"
}
}

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

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

@ -1,7 +0,0 @@
{
"name": "valid",
"launch_path": "/wrong-path.html",
"icons": {
"128": "/icon.png"
}
}

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

@ -33,9 +33,3 @@ validator.missIconMarketplace=app submission to the Marketplace needs at least a
validator.invalidAppType=Unknown app type: '%S'.
validator.invalidHostedPriviledges=Hosted App can't be type '%S'.
validator.noCertifiedSupport='certified' apps are not fully supported on the App manager.
validator.nonAbsoluteLaunchPath=Launch path has to be an absolute path starting with '/': '%S'
validator.invalidLaunchPath=Unable to access to app starting document '%S'
# LOCALIZATION NOTE (validator.invalidLaunchPathBadHttpCode): %1$S is the URI of
# the launch document, %2$S is the http error code.
validator.invalidLaunchPathBadHttpCode=Unable to access to app starting document '%1$S', got HTTP code %2$S