summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/appmanifest/orientation-member
diff options
context:
space:
mode:
Diffstat (limited to 'testing/web-platform/tests/appmanifest/orientation-member')
-rw-r--r--testing/web-platform/tests/appmanifest/orientation-member/orientation-member-landscape-manual.html25
-rw-r--r--testing/web-platform/tests/appmanifest/orientation-member/orientation-member-portrait-manual.html25
-rw-r--r--testing/web-platform/tests/appmanifest/orientation-member/orientation-member-service-worker.js53
-rw-r--r--testing/web-platform/tests/appmanifest/orientation-member/resources/icon.pngbin0 -> 9871 bytes
-rw-r--r--testing/web-platform/tests/appmanifest/orientation-member/resources/orientation-member-landscape.webmanifest12
-rw-r--r--testing/web-platform/tests/appmanifest/orientation-member/resources/orientation-member-landscape.webmanifest.headers1
-rw-r--r--testing/web-platform/tests/appmanifest/orientation-member/resources/orientation-member-manual.js4
-rw-r--r--testing/web-platform/tests/appmanifest/orientation-member/resources/orientation-member-portrait.webmanifest12
-rw-r--r--testing/web-platform/tests/appmanifest/orientation-member/resources/orientation-member-portrait.webmanifest.headers1
9 files changed, 133 insertions, 0 deletions
diff --git a/testing/web-platform/tests/appmanifest/orientation-member/orientation-member-landscape-manual.html b/testing/web-platform/tests/appmanifest/orientation-member/orientation-member-landscape-manual.html
new file mode 100644
index 0000000000..8df1117964
--- /dev/null
+++ b/testing/web-platform/tests/appmanifest/orientation-member/orientation-member-landscape-manual.html
@@ -0,0 +1,25 @@
+<!DOCTYPE html>
+<title>Test that orientation member with landscape value is supported</title>
+<link rel="help" href="https://w3c.github.io/manifest#orientation-member" />
+<link rel="manifest" href="resources/orientation-member-landscape.webmanifest" />
+<script src="resources/orientation-member-manual.js"></script>
+<meta name="viewport" content="width=device-width, initial-scale=1">
+<h1>Testing support for orientation member with "landscape" value</h1>
+<style>
+ @media all and (orientation: landscape) {
+ body {
+ background-color: green;
+ }
+ }
+ @media all and (orientation: portrait) {
+ body {
+ background-color: red;
+ }
+ }
+</style>
+<p>
+ Please set the phone orientation to portrait.
+</p>
+<p>
+ To pass, after installing the display orientation must be landscape and the background must be green.
+</p>
diff --git a/testing/web-platform/tests/appmanifest/orientation-member/orientation-member-portrait-manual.html b/testing/web-platform/tests/appmanifest/orientation-member/orientation-member-portrait-manual.html
new file mode 100644
index 0000000000..ed866f3561
--- /dev/null
+++ b/testing/web-platform/tests/appmanifest/orientation-member/orientation-member-portrait-manual.html
@@ -0,0 +1,25 @@
+<!DOCTYPE html>
+<title>Test that orientation member with portrait value is supported</title>
+<link rel="help" href="https://w3c.github.io/manifest#orientation-member" />
+<link rel="manifest" href="resources/orientation-member-portrait.webmanifest" />
+<script src="resources/orientation-member-manual.js"></script>
+<meta name="viewport" content="width=device-width, initial-scale=1">
+<h1>Testing support for orientation member with "portrait" value</h1>
+<style>
+ @media all and (orientation: portrait) {
+ body {
+ background-color: green;
+ }
+ }
+ @media all and (orientation: landscape) {
+ body {
+ background-color: red;
+ }
+ }
+</style>
+<p>
+ Please set the phone orientation to landscape.
+</p>
+<p>
+ To pass, after installing the display orientation must be portrait and the background must be green.
+</p>
diff --git a/testing/web-platform/tests/appmanifest/orientation-member/orientation-member-service-worker.js b/testing/web-platform/tests/appmanifest/orientation-member/orientation-member-service-worker.js
new file mode 100644
index 0000000000..26f53c9816
--- /dev/null
+++ b/testing/web-platform/tests/appmanifest/orientation-member/orientation-member-service-worker.js
@@ -0,0 +1,53 @@
+// Some user agents only offer app installation if there is a SW and it handles
+// offline requests.
+
+const cacheVersion = "1.2";
+const CACHE_NAME = `cache-v${cacheVersion}`;
+
+// The resources cached by this service worker.
+const resources = [
+ "orientation-member-landscape-manual.html",
+ "orientation-member-portrait-manual.html",
+ "orientation-member-service-worker.js",
+ "resources/orientation-member-manual.js",
+ "resources/icon.png",
+];
+
+// Load all resources for this service worker.
+const precache = async () => {
+ const cache = await caches.open(CACHE_NAME);
+ await cache.addAll(resources);
+};
+
+// Get a resource from the cache.
+const fromCache = async request => {
+ const cache = await caches.open(CACHE_NAME);
+ return await cache.match(request.url);
+};
+
+// Attempt to get resources from the network first, fallback to the cache if we're
+// offline.
+const networkFallbackToCache = async request => {
+ try {
+ const response = await fetch(request);
+ if (response.ok) return response;
+ } catch (err) {}
+ return await fromCache(request);
+};
+
+// When we have a new service worker, update the caches and swap immediately.
+self.addEventListener("install", e => {
+ e.waitUntil(precache().then(() => self.skipWaiting()));
+});
+
+// Claim existing clients.
+self.addEventListener("activate", e => {
+ e.waitUntil(self.clients.claim());
+});
+
+// When a resource need to be fetched, check whether it is
+// contained in the cache and return the cached version, otherwise
+// get it from the network.
+self.addEventListener("fetch", e => {
+ e.respondWith(networkFallbackToCache(e.request));
+});
diff --git a/testing/web-platform/tests/appmanifest/orientation-member/resources/icon.png b/testing/web-platform/tests/appmanifest/orientation-member/resources/icon.png
new file mode 100644
index 0000000000..fecb1d2da4
--- /dev/null
+++ b/testing/web-platform/tests/appmanifest/orientation-member/resources/icon.png
Binary files differ
diff --git a/testing/web-platform/tests/appmanifest/orientation-member/resources/orientation-member-landscape.webmanifest b/testing/web-platform/tests/appmanifest/orientation-member/resources/orientation-member-landscape.webmanifest
new file mode 100644
index 0000000000..c930d292e5
--- /dev/null
+++ b/testing/web-platform/tests/appmanifest/orientation-member/resources/orientation-member-landscape.webmanifest
@@ -0,0 +1,12 @@
+{
+ "name": "Orientation member with landscape value WPT",
+ "icons": [
+ {
+ "src": "icon.png",
+ "sizes": "192x192"
+ }
+ ],
+ "start_url": "../orientation-member-landscape-manual.html",
+ "display": "standalone",
+ "orientation": "landscape"
+}
diff --git a/testing/web-platform/tests/appmanifest/orientation-member/resources/orientation-member-landscape.webmanifest.headers b/testing/web-platform/tests/appmanifest/orientation-member/resources/orientation-member-landscape.webmanifest.headers
new file mode 100644
index 0000000000..2bab061d43
--- /dev/null
+++ b/testing/web-platform/tests/appmanifest/orientation-member/resources/orientation-member-landscape.webmanifest.headers
@@ -0,0 +1 @@
+Content-Type: application/manifest+json; charset=utf-8
diff --git a/testing/web-platform/tests/appmanifest/orientation-member/resources/orientation-member-manual.js b/testing/web-platform/tests/appmanifest/orientation-member/resources/orientation-member-manual.js
new file mode 100644
index 0000000000..6929c997a4
--- /dev/null
+++ b/testing/web-platform/tests/appmanifest/orientation-member/resources/orientation-member-manual.js
@@ -0,0 +1,4 @@
+if ('serviceWorker' in navigator) {
+ navigator.serviceWorker.register(
+ 'orientation-member-service-worker.js');
+}
diff --git a/testing/web-platform/tests/appmanifest/orientation-member/resources/orientation-member-portrait.webmanifest b/testing/web-platform/tests/appmanifest/orientation-member/resources/orientation-member-portrait.webmanifest
new file mode 100644
index 0000000000..7ddf0851ac
--- /dev/null
+++ b/testing/web-platform/tests/appmanifest/orientation-member/resources/orientation-member-portrait.webmanifest
@@ -0,0 +1,12 @@
+{
+ "name": "Orientation member with portrait value WPT",
+ "icons": [
+ {
+ "src": "icon.png",
+ "sizes": "192x192"
+ }
+ ],
+ "start_url": "../orientation-member-portrait-manual.html",
+ "display": "standalone",
+ "orientation": "portrait"
+}
diff --git a/testing/web-platform/tests/appmanifest/orientation-member/resources/orientation-member-portrait.webmanifest.headers b/testing/web-platform/tests/appmanifest/orientation-member/resources/orientation-member-portrait.webmanifest.headers
new file mode 100644
index 0000000000..2bab061d43
--- /dev/null
+++ b/testing/web-platform/tests/appmanifest/orientation-member/resources/orientation-member-portrait.webmanifest.headers
@@ -0,0 +1 @@
+Content-Type: application/manifest+json; charset=utf-8