Backed out changesets 45b199e32b8e, 0b7c44eff352, and 763edcbd5757 (bug 912918) for test_app_validator.html timeouts.

This commit is contained in:
Ryan VanderMeulen 2013-11-07 16:35:18 -05:00
parent 1839307160
commit 191c040091
6 changed files with 33 additions and 78 deletions

View File

@ -1,9 +1,8 @@
/* 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";
let {Ci,Cu,CC} = require("chrome");
let {Ci,Cu,CC,Cc} = require("chrome");
const promise = require("sdk/core/promise");
const {FileUtils} = Cu.import("resource://gre/modules/FileUtils.jsm");
@ -19,11 +18,11 @@ function AppValidator(project) {
AppValidator.prototype.error = function (message) {
this.errors.push(message);
};
}
AppValidator.prototype.warning = function (message) {
this.warnings.push(message);
};
}
AppValidator.prototype._getPackagedManifestFile = function () {
let manifestFile = FileUtils.File(this.project.location);
@ -86,7 +85,7 @@ AppValidator.prototype._fetchManifest = function (manifestURL) {
}
return deferred.promise;
};
}
AppValidator.prototype._getManifest = function () {
let manifestURL;
@ -107,28 +106,29 @@ AppValidator.prototype._getManifest = function () {
return promise.resolve(null);
}
return this._fetchManifest(manifestURL);
};
}
AppValidator.prototype.validateManifest = function (manifest) {
if (!manifest.name) {
this.error(strings.GetStringFromName("validator.missNameManifestProperty"));
return;
}
if (!manifest.icons || Object.keys(manifest.icons).length === 0) {
if (!manifest.icons || Object.keys(manifest.icons).length == 0) {
this.warning(strings.GetStringFromName("validator.missIconsManifestProperty"));
} else if (!manifest.icons["128"]) {
this.warning(strings.GetStringFromName("validator.missIconMarketplace"));
}
};
}
AppValidator.prototype._getOriginURL = function () {
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();
@ -181,7 +181,7 @@ AppValidator.prototype.validateLaunchPath = function (manifest) {
}
return deferred.promise;
};
}
AppValidator.prototype.validateType = function (manifest) {
let appType = manifest.type || "web";
@ -196,7 +196,7 @@ AppValidator.prototype.validateType = function (manifest) {
if (appType === "certified") {
this.warning(strings.GetStringFromName("validator.noCertifiedSupport"));
}
};
}
AppValidator.prototype.validate = function () {
this.errors = [];
@ -210,6 +210,7 @@ AppValidator.prototype.validate = function () {
return this.validateLaunchPath(manifest);
}
}).bind(this));
};
}
exports.AppValidator = AppValidator;

View File

@ -173,10 +173,6 @@ let UI = {
project.errorsCount = 0;
}
if (project.warningsCount && project.errorsCount) {
project.validationStatus = "error warning";
}
});
},

View File

@ -64,9 +64,7 @@
<div class="project-title">
<h1 template='{"type":"textContent","path":"manifest.name"}'></h1>
<div class="project-status" template='{"type":"attribute","path":"validationStatus","name":"status"}'>
<p class="project-validation valid">&projects.valid;</p>
<p class="project-validation warning">&projects.warning;</p>
<p class="project-validation error">&projects.error;</p>
<p class="project-validation" template='{"type":"textContent","path":"validationStatus"}'></p>
<p class="project-type" template='{"type":"textContent","path":"type"}'></p>
</div>
</div>

View File

@ -141,34 +141,8 @@
next();
});
},
// Test multiple failures (missing name [error] and icon [warning])
function () {
let validator = createHosted("no-name-or-icon");
validator.validate().then(() => {
checkNoNameOrIcon(validator);
});
},
function () {
let validator = createPackaged("no-name-or-icon");
validator.validate().then(() => {
checkNoNameOrIcon(validator);
});
}
];
function checkNoNameOrIcon(validator) {
is(validator.errors.length, 1, "app with no name has an error");
is(validator.errors[0],
strings.GetStringFromName("validator.missNameManifestProperty"),
"with expected message");
is(validator.warnings.length, 1, "app with no icon has a warning");
is(validator.warnings[0],
strings.GetStringFromName("validator.missIconsManifestProperty"),
"with expected message");
next();
}
</script>
</body>
</html>

View File

@ -78,9 +78,6 @@
<!ENTITY projects.manifestEditorTooltip "Edit your app's manifest in the panel below. The Update button will save your changes and update the app.">
<!ENTITY projects.manifestViewer "Manifest Viewer">
<!ENTITY projects.manifestViewerTooltip "Examine your app's manifest in the panel below.">
<!ENTITY projects.valid "Valid">
<!ENTITY projects.error "Error">
<!ENTITY projects.warning "Warning">
<!ENTITY help.title "App Manager">
<!ENTITY help.close "Close">

View File

@ -124,15 +124,15 @@ strong {
box-shadow: inset 0 0 1px 1px rgba(255,255,255,0.2), inset 0 -1px 0 0 rgba(0,0,0,0.2);
}
.project-item-status[status="warning"] {
background-color: #F2B33F;
}
.project-item-status[status="valid"] {
background-color: #70BF53;
}
.project-item-status[status~="warning"] {
background-color: #F2B33F;
}
.project-item-status[status~="error"] {
.project-item-status[status="error"] {
background-color: #ED4C62;
}
@ -315,27 +315,20 @@ strong {
.project-validation {
color: #FFF;
display: none;
margin-left: 10px;
}
.project-validation.valid {
[status="valid"] > .project-validation {
background-color: #70BF53;
}
.project-validation.warning {
[status="warning"] > .project-validation {
background-color: #F2B33F;
}
.project-validation.error {
[status="error"] > .project-validation {
background-color: #ED4C62;
}
[status="valid"] > .project-validation.valid,
[status~="warning"] > .project-validation.warning,
[status~="error"] > .project-validation.error {
display: inline;
}
/********* PROJECT BUTTONS ***********/
@ -406,31 +399,27 @@ strong {
display: none;
}
[status~="warning"] .project-item-warnings,
[status~="error"] .project-item-errors {
display: inline-block;
}
[status~="warning"] > .project-warnings,
[status~="error"] > .project-errors {
[status="warning"] > .project-item-warnings,
[status="error"] > .project-item-errors,
[status="warning"] > .project-warnings,
[status="error"] > .project-errors {
display: block;
}
.project-warnings,
.project-errors {
.project-warnings {
margin: 20px 20px 0;
padding: 10px 10px;
border-left: 3px solid #ECB51E;
background-color: rgba(236, 181, 20, 0.1);
font-family: monospace;
}
.project-warnings {
border-left: 3px solid #ECB51E;
background-color: rgba(236, 181, 20, 0.1);
}
.project-errors {
margin: 20px;
padding: 10px 10px;
border-left: 3px solid #ED4C62;
background-color: rgba(237,76,98,0.1);
font-family: monospace;
}
.project-item-warnings {