Skip to content
This repository has been archived by the owner on Nov 3, 2021. It is now read-only.

Commit

Permalink
Bug 1088009 - merge pull request #28310 from benfrancis:1088009-2 to …
Browse files Browse the repository at this point in the history
…mozilla-b2g:master
  • Loading branch information
mozilla-autolander-deprecated committed Feb 20, 2015
2 parents debb64a + e5928de commit 08e0eee
Show file tree
Hide file tree
Showing 10 changed files with 208 additions and 15 deletions.
61 changes: 46 additions & 15 deletions apps/system/js/app_window.js
Expand Up @@ -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;
Expand All @@ -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;
}
};

/**
Expand Down
5 changes: 5 additions & 0 deletions apps/system/test/marionette/lib/system.js
Expand Up @@ -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',
Expand Down Expand Up @@ -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);
Expand Down
10 changes: 10 additions & 0 deletions apps/system/test/marionette/web_app_fullscreen/index.html
@@ -0,0 +1,10 @@
<!DOCTYPE html>
<html>
<head>
<title>Fullscreen Web App</title>
<link rel="manifest" href="manifest.webapp">
</head>
<body>
<h1>Fullscreen W3C Web App</h1>
</body>
</html>
@@ -0,0 +1,5 @@
{
"name": "Fullscreen W3C Web App",
"display": "fullscreen",
"launch_path": "/index.html"
}
10 changes: 10 additions & 0 deletions apps/system/test/marionette/web_app_minimal_ui/index.html
@@ -0,0 +1,10 @@
<!DOCTYPE html>
<html>
<head>
<title>Minimal UI W3C Web App</title>
<link rel="manifest" href="manifest.webapp">
</head>
<body>
<h1>Minimal UI W3C Web App</h1>
</body>
</html>
@@ -0,0 +1,5 @@
{
"name": "Minimal UI W3C Web App",
"display": "minimal-ui",
"launch_path": "/index.html"
}
10 changes: 10 additions & 0 deletions apps/system/test/marionette/web_app_standalone/index.html
@@ -0,0 +1,10 @@
<!DOCTYPE html>
<html>
<head>
<title>Standalone W3C Web App</title>
<link rel="manifest" href="manifest.webapp">
</head>
<body>
<h1>Standalone W3C Web App</h1>
</body>
</html>
@@ -0,0 +1,5 @@
{
"name": "Standalone W3C Web App",
"display": "standalone",
"launch_path": "/index.html"
}
62 changes: 62 additions & 0 deletions 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);
});
});
50 changes: 50 additions & 0 deletions apps/system/test/unit/app_window_test.js
Expand Up @@ -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;
Expand Down

0 comments on commit 08e0eee

Please sign in to comment.