diff --git a/apps/system/js/app_window.js b/apps/system/js/app_window.js
index 184664be81e5..c63809646d9a 100644
--- a/apps/system/js/app_window.js
+++ b/apps/system/js/app_window.js
@@ -130,21 +130,6 @@
this.browser_config = configuration;
// Store initial configuration in this.config
this.config = configuration;
- this.config.chrome = (this.manifest && this.manifest.chrome) ?
- this.manifest.chrome :
- this.config.chrome;
-
- if (!this.config.chrome) {
- this.config.chrome = {
- scrollable: this.isBrowser(),
- maximized: this.isBrowser()
- };
- } else if (this.config.chrome.navigation) {
- this.config.chrome.scrollable = !this.isFullScreen();
- // This is for backward compatibility with application that
- // requests the |navigation| flag in their manifest.
- this.config.chrome.maximized = true;
- }
if (this.manifest) {
this.shortName = new ManifestHelper(this.manifest).short_name;
@@ -169,6 +154,52 @@
} else if (this.rearWindow) {
this.rearWindow.setFrontWindow(this);
}
+
+ // W3C web app manifest "display" property takes precedence
+ if (this.manifest && this.manifest.display) {
+ switch(this.manifest.display) {
+ case 'fullscreen':
+ this._fullScreen = true;
+ this.config.chrome = {
+ scrollable: false,
+ maximized: false,
+ };
+ return; // Early return
+ case 'standalone':
+ this.config.chrome = {
+ scrollable: false,
+ maximized: false,
+ };
+ return;
+ case 'minimal-ui':
+ case 'browser':
+ this.config.chrome = {
+ navigation: true, //AppChrome checks for this
+ scrollable: true,
+ maximized: true
+ };
+ return;
+ default:
+ console.error('Invalid display property in web app manifest.');
+ }
+ }
+
+ // Fall back to mozApp manifest chrome and fullscreen properties
+ this.config.chrome = (this.manifest && this.manifest.chrome) ?
+ this.manifest.chrome :
+ this.config.chrome;
+
+ if (!this.config.chrome) {
+ this.config.chrome = {
+ scrollable: this.isBrowser(),
+ maximized: this.isBrowser()
+ };
+ } else if (this.config.chrome.navigation) {
+ this.config.chrome.scrollable = !this.isFullScreen();
+ // This is for backward compatibility with application that
+ // requests the |navigation| flag in their manifest.
+ this.config.chrome.maximized = true;
+ }
};
/**
diff --git a/apps/system/test/marionette/lib/system.js b/apps/system/test/marionette/lib/system.js
index 8094c509b268..d8009e4af7d8 100644
--- a/apps/system/test/marionette/lib/system.js
+++ b/apps/system/test/marionette/lib/system.js
@@ -40,6 +40,7 @@ System.Selector = Object.freeze({
appChromeWindowsButton: '.appWindow.active .controls .windows-button',
appChromeProgressBar: '.appWindow.active .chrome gaia-progress',
browserWindow: '.appWindow.browser',
+ currentWindow: '.appWindow.active',
dialogOverlay: '#screen #dialog-overlay',
downloadDialog: '#downloadConfirmUI',
imeMenu: '.ime-menu',
@@ -182,6 +183,10 @@ System.prototype = {
System.Selector.appChromeProgressBar);
},
+ get currentWindow() {
+ return this.client.helper.waitForElement(System.Selector.currentWindow);
+ },
+
get dialogOverlay() {
return this.client.helper.waitForElement(
System.Selector.dialogOverlay);
diff --git a/apps/system/test/marionette/web_app_fullscreen/index.html b/apps/system/test/marionette/web_app_fullscreen/index.html
new file mode 100644
index 000000000000..dc125608d094
--- /dev/null
+++ b/apps/system/test/marionette/web_app_fullscreen/index.html
@@ -0,0 +1,10 @@
+
+
+
+ Fullscreen Web App
+
+
+
+ Fullscreen W3C Web App
+
+
diff --git a/apps/system/test/marionette/web_app_fullscreen/manifest.webapp b/apps/system/test/marionette/web_app_fullscreen/manifest.webapp
new file mode 100644
index 000000000000..0b875b570fd7
--- /dev/null
+++ b/apps/system/test/marionette/web_app_fullscreen/manifest.webapp
@@ -0,0 +1,5 @@
+{
+ "name": "Fullscreen W3C Web App",
+ "display": "fullscreen",
+ "launch_path": "/index.html"
+}
diff --git a/apps/system/test/marionette/web_app_minimal_ui/index.html b/apps/system/test/marionette/web_app_minimal_ui/index.html
new file mode 100644
index 000000000000..958940f191ab
--- /dev/null
+++ b/apps/system/test/marionette/web_app_minimal_ui/index.html
@@ -0,0 +1,10 @@
+
+
+
+ Minimal UI W3C Web App
+
+
+
+ Minimal UI W3C Web App
+
+
diff --git a/apps/system/test/marionette/web_app_minimal_ui/manifest.webapp b/apps/system/test/marionette/web_app_minimal_ui/manifest.webapp
new file mode 100644
index 000000000000..05938ac62d50
--- /dev/null
+++ b/apps/system/test/marionette/web_app_minimal_ui/manifest.webapp
@@ -0,0 +1,5 @@
+{
+ "name": "Minimal UI W3C Web App",
+ "display": "minimal-ui",
+ "launch_path": "/index.html"
+}
diff --git a/apps/system/test/marionette/web_app_standalone/index.html b/apps/system/test/marionette/web_app_standalone/index.html
new file mode 100644
index 000000000000..1f7c9c5e1710
--- /dev/null
+++ b/apps/system/test/marionette/web_app_standalone/index.html
@@ -0,0 +1,10 @@
+
+
+
+ Standalone W3C Web App
+
+
+
+ Standalone W3C Web App
+
+
diff --git a/apps/system/test/marionette/web_app_standalone/manifest.webapp b/apps/system/test/marionette/web_app_standalone/manifest.webapp
new file mode 100644
index 000000000000..b2664747e399
--- /dev/null
+++ b/apps/system/test/marionette/web_app_standalone/manifest.webapp
@@ -0,0 +1,5 @@
+{
+ "name": "Standalone W3C Web App",
+ "display": "standalone",
+ "launch_path": "/index.html"
+}
diff --git a/apps/system/test/marionette/web_manifest_display_test.js b/apps/system/test/marionette/web_manifest_display_test.js
new file mode 100644
index 000000000000..27a81dd68c74
--- /dev/null
+++ b/apps/system/test/marionette/web_manifest_display_test.js
@@ -0,0 +1,62 @@
+'use strict';
+
+var assert = require('assert');
+
+marionette('Web Manifest Display Modes >', function() {
+
+ var client = marionette.client({
+ prefs: {
+ 'dom.w3c_touch_events.enabled': 1
+ },
+ settings: {
+ 'ftu.manifestURL': null,
+ 'lockscreen.enabled': false
+ },
+ apps: {
+ 'web_app_minimal_ui.gaiamobile.org': __dirname + '/web_app_minimal_ui',
+ 'web_app_standalone.gaiamobile.org': __dirname + '/web_app_standalone',
+ 'web_app_fullscreen.gaiamobile.org': __dirname + '/web_app_fullscreen'
+ }
+ });
+
+ var system, frame;
+
+ setup(function() {
+ system = client.loader.getAppClass('system');
+ system.waitForStartup();
+ });
+
+ test('minimal-ui', function() {
+ var appOrigin = 'app://web_app_minimal_ui.gaiamobile.org';
+ frame = system.waitForLaunch(appOrigin);
+ client.switchToFrame(frame);
+ client.helper.waitForElement('body');
+ client.switchToFrame();
+ var windowClass = system.currentWindow.getAttribute('class');
+ assert.ok(windowClass.indexOf('collapsible') != -1);
+ assert.ok(windowClass.indexOf('scrollable') != -1);
+ });
+
+ test('standalone', function() {
+ var appOrigin = 'app://web_app_standalone.gaiamobile.org';
+ frame = system.waitForLaunch(appOrigin);
+ client.switchToFrame(frame);
+ client.helper.waitForElement('body');
+ client.switchToFrame();
+ var windowClass = system.currentWindow.getAttribute('class');
+ assert.ok(windowClass.indexOf('collapsible') == -1);
+ assert.ok(windowClass.indexOf('scrollable') == -1);
+ });
+
+ test('fullscreen', function() {
+ var appOrigin = 'app://web_app_fullscreen.gaiamobile.org';
+ frame = system.waitForLaunch(appOrigin);
+ client.switchToFrame(frame);
+ client.helper.waitForElement('body');
+ client.switchToFrame();
+ var windowClass = system.currentWindow.getAttribute('class');
+ assert.ok(windowClass.indexOf('collapsible') == -1);
+ assert.ok(windowClass.indexOf('scrollable') == -1);
+ assert.ok(windowClass.indexOf('fullscreen-app') != -1);
+ });
+});
diff --git a/apps/system/test/unit/app_window_test.js b/apps/system/test/unit/app_window_test.js
index b44563f8d438..681088d7957a 100644
--- a/apps/system/test/unit/app_window_test.js
+++ b/apps/system/test/unit/app_window_test.js
@@ -631,6 +631,56 @@ suite('system/AppWindow', function() {
});
});
+ suite('Display Modes', function() {
+ var fakeAppConfigDisplayMinimalUi = {
+ url: 'http://www.fake/index.html',
+ manifest: {
+ 'display': 'minimal-ui'
+ },
+ manifestURL: 'app://wwww.fake/ManifestURL',
+ origin: 'app://www.fake'
+ };
+
+ var fakeAppConfigDisplayStandalone = {
+ url: 'http://www.fake/index.html',
+ manifest: {
+ 'display': 'standalone'
+ },
+ manifestURL: 'app://wwww.fake/ManifestURL',
+ origin: 'app://www.fake'
+ };
+
+ var fakeAppConfigDisplayFullscreen = {
+ url: 'http://www.fake/index.html',
+ manifest: {
+ 'display': 'fullscreen'
+ },
+ manifestURL: 'app://wwww.fake/ManifestURL',
+ origin: 'app://www.fake'
+ };
+
+ test('minimal-ui', function() {
+ var app1 = new AppWindow(fakeAppConfigDisplayMinimalUi);
+ assert.isFalse(app1.isFullScreen());
+ assert.isTrue(app1.config.chrome.scrollable);
+ assert.isTrue(app1.config.chrome.maximized);
+ });
+
+ test('standalone', function() {
+ var app1 = new AppWindow(fakeAppConfigDisplayStandalone);
+ assert.isFalse(app1.isFullScreen());
+ assert.isFalse(app1.config.chrome.scrollable);
+ assert.isFalse(app1.config.chrome.maximized);
+ });
+
+ test('fullscreen', function() {
+ var app1 = new AppWindow(fakeAppConfigDisplayFullscreen);
+ assert.isTrue(app1.isFullScreen());
+ assert.isFalse(app1.config.chrome.scrollable);
+ assert.isFalse(app1.config.chrome.maximized);
+ });
+ });
+
suite('ScreenshotOverlay State Control', function() {
var app1;
var app2;