mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1017029 - [appmgr v2] Validation is not triggered after the manifest file has changed. r=ochameau
This commit is contained in:
parent
f234e27a93
commit
12ef4d0e69
@ -472,8 +472,8 @@ exports.AppManager = AppManager = {
|
||||
yield AppProjects.update(project);
|
||||
}
|
||||
|
||||
if (this.selectedProject === project) {
|
||||
this.update("project-validated");
|
||||
if (AppManager.selectedProject === project) {
|
||||
AppManager.update("project-validated");
|
||||
}
|
||||
});
|
||||
},
|
||||
|
@ -12,3 +12,4 @@ support-files =
|
||||
[test_import.html]
|
||||
[test_runtime.html]
|
||||
[test_cli.html]
|
||||
[test_manifestUpdate.html]
|
||||
|
101
browser/devtools/webide/test/test_manifestUpdate.html
Normal file
101
browser/devtools/webide/test/test_manifestUpdate.html
Normal file
@ -0,0 +1,101 @@
|
||||
<!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>
|
||||
<script type="application/javascript;version=1.8" src="head.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">
|
||||
window.onload = function() {
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
let {TextDecoder, OS} = Cu.import("resource://gre/modules/osfile.jsm", {});
|
||||
|
||||
Task.spawn(function* () {
|
||||
let win = yield openWebIDE();
|
||||
let AppManager = win.AppManager;
|
||||
|
||||
function isProjectMarkedAsValid() {
|
||||
let details = win.UI.projecteditor.window.frames[0];
|
||||
return !details.document.body.classList.contains("error");
|
||||
}
|
||||
|
||||
let packagedAppLocation = getTestFilePath("app");
|
||||
|
||||
yield win.Cmds.importPackagedApp(packagedAppLocation);
|
||||
|
||||
let project = win.AppManager.selectedProject;
|
||||
|
||||
let deferred = promise.defer();
|
||||
win.UI.projecteditor.once("onEditorCreated", deferred.resolve);
|
||||
yield deferred.promise;
|
||||
|
||||
ok("name" in project.manifest, "manifest includes name");
|
||||
is(project.name, project.manifest.name, "Display name uses manifest name");
|
||||
ok(isProjectMarkedAsValid(), "project is marked as valid");
|
||||
|
||||
// Change the name
|
||||
let originalName = project.manifest.name;
|
||||
|
||||
project.manifest.name = "xxx";
|
||||
|
||||
// Write to disk
|
||||
yield AppManager.writeManifest(project);
|
||||
|
||||
// Read file
|
||||
let manifestPath = OS.Path.join(packagedAppLocation, "manifest.webapp");
|
||||
let Decoder = new TextDecoder();
|
||||
let data = yield OS.File.read(manifestPath);
|
||||
data = new TextDecoder().decode(data);
|
||||
let json = JSON.parse(data);
|
||||
is(json.name, "xxx", "manifest written on disc");
|
||||
|
||||
// Make the manifest invalid on disk
|
||||
delete json.name
|
||||
let Encoder = new TextEncoder();
|
||||
data = Encoder.encode(JSON.stringify(json));
|
||||
yield OS.File.writeAtomic(manifestPath, data , {tmpPath: manifestPath + ".tmp"});
|
||||
|
||||
// Trigger validation
|
||||
yield AppManager.validateProject(AppManager.selectedProject);
|
||||
yield nextTick();
|
||||
|
||||
ok(!("name" in project.manifest), "manifest has been updated");
|
||||
is(project.name, "--", "Placeholder is used for display name");
|
||||
ok(!isProjectMarkedAsValid(), "project is marked as invalid");
|
||||
|
||||
// Make the manifest valid on disk
|
||||
project.manifest.name = originalName;
|
||||
yield AppManager.writeManifest(project);
|
||||
|
||||
// Trigger validation
|
||||
yield AppManager.validateProject(AppManager.selectedProject);
|
||||
yield nextTick();
|
||||
|
||||
ok("name" in project.manifest, "manifest includes name");
|
||||
is(project.name, originalName, "Display name uses original manifest name");
|
||||
ok(isProjectMarkedAsValid(), "project is marked as valid");
|
||||
|
||||
yield closeWebIDE(win);
|
||||
|
||||
yield removeAllProjects();
|
||||
|
||||
SimpleTest.finish();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user