michael@0: Cu.import("resource://gre/modules/XPCOMUtils.jsm"); michael@0: Cu.import("resource://webapprt/modules/WebappRT.jsm"); michael@0: michael@0: function test() { michael@0: waitForExplicitFinish(); michael@0: michael@0: loadWebapp("window-title.webapp", undefined, function onLoad() { michael@0: is(document.documentElement.getAttribute("title"), michael@0: WebappRT.config.app.manifest.name, michael@0: "initial window title should be webapp name"); michael@0: michael@0: // Tests are triples of [URL to load, expected window title, test message]. michael@0: let tests = [ michael@0: ["http://example.com/webapprtChrome/webapprt/test/chrome/window-title.html", michael@0: "http://example.com" + " - " + WebappRT.config.app.manifest.name, michael@0: "window title should show origin of page at different origin"], michael@0: ["http://test/webapprtChrome/webapprt/test/chrome/window-title.html", michael@0: WebappRT.config.app.manifest.name, michael@0: "after returning to app origin, window title should no longer show origin"], michael@0: ]; michael@0: michael@0: let title, message; michael@0: michael@0: let progressListener = { michael@0: QueryInterface: XPCOMUtils.generateQI([Ci.nsIWebProgressListener, michael@0: Ci.nsISupportsWeakReference]), michael@0: onLocationChange: function onLocationChange(progress, request, location, michael@0: flags) { michael@0: // Do test in timeout to give runtime time to change title. michael@0: window.setTimeout(function() { michael@0: is(document.documentElement.getAttribute("title"), title, message); michael@0: testNext(); michael@0: }, 0); michael@0: } michael@0: }; michael@0: michael@0: gAppBrowser.addProgressListener(progressListener, michael@0: Ci.nsIWebProgress.NOTIFY_LOCATION); michael@0: michael@0: function testNext() { michael@0: if (!tests.length) { michael@0: gAppBrowser.removeProgressListener(progressListener); michael@0: gAppBrowser.stop(); michael@0: finish(); michael@0: return; michael@0: } michael@0: michael@0: [gAppBrowser.contentDocument.location, title, message] = tests.shift(); michael@0: } michael@0: michael@0: testNext(); michael@0: }); michael@0: }