This repository has been archived by the owner on Jan 19, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
index.html
709 lines (599 loc) · 26.9 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
<!DOCTYPE html>
<html>
<head>
<meta name="generator" content=
"HTML Tidy for HTML5 (experimental) for Mac OS X https://github.com/w3c/tidy-html5/tree/c63cc39">
<title>Web Application Manifest Format and Management APIs</title>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8'>
<script class="remove" src="http://www.w3.org/Tools/respec/respec-w3c-common"
type="text/javascript">
<!-- keep this comment -->
</script>
<script class="remove" src="webapps.js" type="text/javascript">
<!-- keep this comment -->
</script>
<style>
ul.properties > li {
margin-bottom: 1.5em;
}
ul > li {
margin: 0.5em;
}
table {
border: 1px dashed black;
margin: 1em;
}
td, th {
border: 1px solid black;
padding: 0.5em;
}
</style>
</head>
<body>
<section id='abstract'>
This document specifies a JSON based format to describe installable web
applications. In addition, a set of JavaScript APIs are described that
allow web content to trigger installation of such applications, as well as
manage them on behalf of the user.
</section>
<section>
<h2>App Manifest</h2>
<p>An application <dfn>manifest</dfn> is a JSON file describing an
installable web application. This JSON file consists of a top-level object
and several properties.</p>
<section>
<h2>Example</h2>
<pre>
{
"name": "MozillaBall",
"description": "Exciting Open Web development action!",
"launch_path": "/",
"version": "1.0",
"type": "privileged",
"icons": {
"16": "/img/icon_16.png",
"48": "/img/icon_48.png",
"128": "/img/icon_128.png"
},
"developer": {
"name": "Mozilla",
"url": "https://mozilla.org/en-US"
},
"installs_allowed_from": [
"https://marketplace.mozilla.org"
],
"appcache_path": "/cache.manifest",
"locales": [
"es": {
"description": "¡Acción abierta emocionante del desarrollo del Web!",
"developer": {
"url": "https://mozilla.org/es-ES"
}
}
],
"default_locale": "en",
"screen_size": {
"min_width": "600",
"min_height": "300"
},
"required_features": [
"touch", "geolocation", "webgl"
],
"orientation": "landscape",
"permissions": {
"contacts": {
"description": "Required for autocompletion in the share screen",
"access": "read"
}
},
"fullscreen": "true",
"activities": {
"share": {
"filters": {
"type": ["image/png", "image/gif"]
}
"href": "/share.html",
"disposition": "window"
}
}
}
</pre>
</section>
<section>
<h2>Properties</h2>
<p class="note">All leaf properties MUST contain string values.</p>
<section>
<h3>Mandatory Properties</h3>
<ul class="properties">
<li><dfn id="propdef-name">name</dfn>: The name of the web application
in the default locale. Maximum length is 128 characters.</li>
<li><dfn id="propdef-description">description</dfn>: A short
description of the web application in the default locale. Maximum
length is 1024 characters.</li>
<li><dfn id="propdef-default_locale">default_locale</dfn>: <i>Mandatory
only if "locales" property is set</i>. The locale of the top-level name
and description.</li>
</ul>
</section>
<section>
<h3>Optional Properties</h3>
<ul class="properties">
<li><dfn id="propdef-launch_path">launch_path</dfn>: The path within
the web application's origin that is loaded when the application is
launched.</li>
<li><dfn id="propdef-icons">icons</dfn>: A map of icon sizes to URIs of
the icons (which may be absolute, relative or data URIs). Icons MUST be
square. Paths beginning with "<code>/</code>" are treated as relative
to the origin of the app.</li>
<li>
<dfn id="propdef-type">type</dfn>: Determines how this app and the
manifest will be verified by the runtime, and what security policy
will apply. See <a href=
"https://wiki.mozilla.org/Apps/Security#Types_of_applications">types
of applications</a>, for a more detailed description. The value for
this property MUST be one of the following:
<ul>
<li>
<dfn id="propdef-type-web">web</dfn>: A regular web app, may be
self hosted or distributed by an app store. All permissions are
opt-in at install and runtime, limited to permissions enumerated
in the manifest. If the <a>type</a> property is not specified,
this will be the default value.
</li>
<li><dfn id="propdef-type-privileged">privileged</dfn>: An
authenticated application approved by an app store. Equivalent in
functionality and security to apps on other mobile platforms, but
is required to be approved by an app store after a code review or
some equivalent risk management process. At install, app assets are
verified & remain stored locally in a package. Requires a
Content Security Policy, and all explicit permissions are requested
at runtime, showing user the app's data usage intentions, and
persisted by default.</li>
<li><dfn id="propdef-type-certified">certified</dfn>: This category
is reserved for apps that require approval by a device vendor or
equivalent party due to risk of device corruption or risk to
critical functionality. These include apps such as the system
settings app, default dialer (to ensure emergency services are
always accessible), core radio and power management, etc. Not
intended for 3rd party applications.</li>
</ul>
</li>
<li>
<dfn id="propdef-developer">developer</dfn>: Information about the
developer of the application, suitable for display.
<ul>
<li><dfn id="propdef-developer-name">name</dfn>: The name of the
developer.</li>
<li><dfn id="propdef-url">url</dfn>: A URL pointing to the
developer's website</li>
</ul>
</li>
<li>
<dfn id="propdef-locales">locales</dfn>: A map of locale specific
overrides of data contained in the manifest. Each locale key is keyed
on a locale tag [RFC4646], and contains a sparse representation of
the manifest. Any field in the <a>locales</a> property will override
the corresponding property in the manifest. The <a>locales</a>,
<a>installs_allowed_from</a>, and <a>default_locale</a> CANNOT be
overridden. If the <a>locales</a> property is set, the
<a>default_locale</a> MUST also be set.
</li>
<li><dfn id=
"propdef-installs_allowed_from">installs_allowed_from</dfn>: An array
of origins that are allowed to trigger installation of this
application. This field allows the developer to restrict installation
of their application to specific sites. If the value is omitted,
installs are allowed from any site.</li>
<li>
<dfn id="propdef-appcache_path">appcache_path</dfn>: The absolute
path to the application cache (<a href=
"http://www.w3.org/TR/2011/WD-html5-20110525/offline.html#appcache">AppCache</a>)
manifest. When an app is installed, the AppCache manifest will be
fetched and parsed, and its static assets under the CACHE header will
be cached.
</li>
<li><dfn id="propdef-version">version</dfn>: A string that represents
the version of this manifest. The User-Agent does not interpret this
value in any way and is opqaue to everyone but the application itself.
The field is provided to help the developer deal with various update
cases, which will be discussed in following sections.</li>
<li><dfn id="propdef-screen_size">screen_size</dfn>: This object may
contain the <code>min_height</code> and <code>min_width</code>
properties that describe the minimum height and width (in pixels) the
application needs in order to render correctly. Interpretation of these
values is left up to the runtime and/or app store.</li>
<li><dfn id="propdef-required_features">required_features</dfn>: This
array consists of a set of values that describes the mandatory features
the application needs in order to run correctly. A full list of valid
values is TBD.</li>
<li>
<dfn id="propdef-orientation">orientation</dfn>: This value defines
the allowed orientations at which the application may be rendered. If
a value is provided, the runtime MUST ensure that the viewport
rendering the application will adhere to one of the specified values
and never orient the application in a direction not specified in this
property. The default behavior SHOULD be to rotate the viewport at an
angle that best fits the orientation of the device, and MUST change
as the user spatially rotates the device. The value MUST be an
array containing one or more of the following string values
(duplicates SHOULD be ignored):
<ul>
<li><dfn id=
"propdef-orientation-portrait-primary">portrait-primary</dfn>:
Locked to a single portrait direction. If the device has an obvious
primary orientation in portrait mode, this is that orientation. If
there is no obvious primary orientation due to landscape being the
primary orientation for the device, this is the orientation if
rotating the device 90 degrees clock-wise from the primary
landscape mode.</li>
<li><dfn id=
"propdef-orientation-landscape-primary">landscape-primary</dfn>:
Locked to a single landscape direction. If the device has an
obvious primary orientation in landscape mode, this is that
orientation. If there is no obvious landscape orientation due to
portrait being the primary orientation for the device, this is the
orientation if rotating the device 90 degrees clock-wise from the
primary portrait mode.</li>
<li>
<dfn id=
"propdef-orientation-portrait-secondary">portrait-secondary</dfn>:
The portrait mode opposite of <a>portrait-primary</a>.
</li>
<li>
<dfn id=
"propdef-orientation-landscape-secondary">landscape-secondary</dfn>:
The landscape mode opposite of <a>landscape-primary</a>.
</li>
<li><dfn id="propdef-orientation-portrait">portrait</dfn>:
Equivalent to
<code>["portrait-primary", "portrait-secondary"]</code>.</li>
<li><dfn id="propdef-orientation-landscape">landscape</dfn>:
Equivalent to
<code>["landscape-primary", "landscape-secondary"]</code>.</li>
</ul>
</li>
<li><dfn id="propdef-permisssions">permissions</dfn>: This value
consists of a set of permissions that the application needs. An
application MUST list every API that is considered to require user
permission in this field. Usage of an API without a corresponding
entry in the manifest will fail. The field is an object, with each
property name specifying a single permission, and object containing
the following fields:
<ul>
<li>
<dfn id="propdef-permissions-desc">description</dfn>: Contains
a human readable string specifying the intent behind requesting
use of this API. This property is mandatory.
</li>
<li>
<dfn id="propdef-permissions-access">access</dfn>: Contains a
a string specifying the type of access required for this
permission. This field is mandatory for a certain subset of
permissions, and MUST be one of <dfn>read</dfn>,
<dfn>readwrite</dfn>, <dfn>readcreate</dfn>, or
<dfn>createonly</dfn>.
</li>
</ul>
The following table lists the various permissions, and whether
they require an <a>access</a> property.
<table>
<tr>
<th>Permission Name</th>
<th>Permission Description</th>
<th>Access Type</th>
</tr>
<tr>
<td><code>alarm</code></td>
<td>Schedule a notification, or for an application to be started,
at a specific time.</td>
<td>-</td>
</tr>
<tr>
<td><code>backgroundservice</code></td>
<td>Enable a web application to run in the background and perform
tasks like syncing or respond to incoming messages.</td>
<td>-</td>
</tr>
<tr>
<td><code>bluetooth</code></td>
<td>Low level access to bluetooth hardware.</td>
<td>-</td>
</tr>
<tr>
<td><code>browser</code></td>
<td>Enables implementing a browser.</td>
<td>-</td>
</tr>
<tr>
<td><code>camera</code></td>
<td>Take photos, shoot video and control the camera.</td>
<td>-</td>
</tr>
<tr>
<td><code>contacts</code></td>
<td>Add, read, or modify contacts from the address book on the
device and read contacts from the SIM.</td>
<td>readonly, readwrite, readcreate, createonly</td>
</tr>
<tr>
<td><code>desktop-notification</code></td>
<td>Display a notification on the user's desktop.</td>
<td>-</td>
</tr>
<tr>
<td><code>device-storage</code></td>
<td>Add, read, or modify files stored at a central location on the
device.</td>
<td>readonly, readwrite, readcreate, createonly</td>
</tr>
<tr>
<td><code>fmradio</code></td>
<td>Control the FM radio.</td>
<td>-</td>
</tr>
<tr>
<td><code>geolocation</code></td>
<td>Obtain the current location of the user.</td>
<td>-</td>
</tr>
<tr>
<td><code>mobileconnection</code></td>
<td>Obtain information about the current mobile voice and data
connection.</td>
<td>-</td>
</tr>
<tr>
<td><code>power</code></td>
<td>Turn the screen on or off, control CPU, device power, etc.
Listen for and inspect resource lock events.</td>
<td>-</td>
</tr>
<tr>
<td><code>push</code></td>
<td>Receive push events.</td>
<td>-</td>
</tr>
<tr>
<td><code>settings</code></td>
<td>Configure or read device settings.</td>
<td>readonly, readwrite</td>
</tr>
<tr>
<td><code>sms</code></td>
<td>Send and receive SMS.</td>
<td>-</td>
</tr>
<tr>
<td><code>storage</code></td>
<td>Utilize localStorage and indexedDB without size limitations.</td>
<td>-</td>
</tr>
<tr>
<td><code>systemclock</code></td>
<td>Set current time. (Timezone information is controlled by the
settings API).</td>
<td>-</td>
</tr>
<tr>
<td><code>network-http</code></td>
<td>Make HTTP requests without any origin restrictions.</td>
<td>-</td>
</tr>
<tr>
<td><code>network-tcp</code></td>
<td>Create and communicate over TCP sockets.</td>
<td>-</td>
</tr>
<tr>
<td><code>telephony</code></td>
<td>All telephony related APIs.</td>
<td>-</td>
</tr>
<tr>
<td><code>wake-lock-screen</code></td>
<td>Turn the display on and show the lock screen.</td>
<td>-</td>
</tr>
<tr>
<td><code>webapps-manage</code></td>
<td>Obtain access to the <code>navigator.apps.mgmt</code> API to
manage installed webapps.</td>
<td>-</td>
</tr>
<tr>
<td><code>wifi</code></td>
<td>Enumerate available WiFi networks, get signal strength, connect
to a network.</td>
<td>-</td>
</tr>
</table>
</li>
<li><dfn id="propdef-fullscreen">fullscreen</dfn>: This value MUST be
set to either <dfn>true</dfn> or <dfn>false</dfn> to describe whether
the runtime should launch the application in fullscreen mode.</li>
<li><dfn id="propdef-activities">activities</dfn>: This value specifies
a set of
<a href="https://wiki.mozilla.org/WebAPI/WebActivities">WebActivities</a>
that this app supports. Each property in this value is a discrete
activity whose name matches the property name. Activity names are
free-form text, and each activity is represented by an object. This
object MUST contain the following property:
<ul>
<li><dfn id="propdef-activities-href">href</dfn>: When another app
or web page initiates an activity that is supported by this app, if
this app is chosen to perform the activity, this page will be opened
in the manner specified by the <dfn>disposition</dfn> property. The
manner in which a particular app is chosen to perform an activity is
out of scope for this specification.</li>
</ul>
An activity object MAY also contain the following properties:
<ul>
<li><dfn id="propdef-activites-disposition">disposition</dfn>: This
value specifies how the page specified in <dfn>href</dfn> is presented
when an activity is invoked. The value, if specified, MUST be one of
the following (if omitted, defaults to <dfn>window</dfn>):
<ul>
<li><dfn id="propdef-activities-disposition-window">window</dfn>:
The page handling the activity is opened in a new "window" (on a
mobile device, for example, this view will replace the original
app that requested the activity). The page MUST call
<code>navigator.setMessageHandler</code> for each activity it
supports and subsequently execute the activity for which it
receives a message. Further, if the activity requires a return
value, the page MUST call <code>activity.postResult</code> or
<code>activity.postError</code> (where <code>activity</code> is
the first argument provided to the function specified by
<code>setMessageHandler</code>) as appropriate. These functions
are specified in greater details in the WebActivities
document.</li>
<li><dfn id="propdef-activities-disposition-inline">inline</dfn>:
The page handling the activity will open in an overlay (on a
mobile device, for example, this will be rendered in a popup over
the original app that requested the activity). Subsequent behavior
is exactly the same as if the disposition were
<dfn>window</dfn>.</li>
</ul>
<li><dfn id="propdef-activities-filters">filters</dfn>:
<i>OPTIONAL</i>. This value is a dictionary, each property of which
specified a particular filter. These filters will be applied while
determining apps suitable for handling a given activity. Filter names
are free-form text, but their values MUST be either a string or an
array of strings (the exact type depends on the filter).</li>
</ul>
</ul>
</section>
</section>
<section>
<h2>Serving Manifests</h2>
<p>An application manifest MUST be served from the same origin that the
application itself is served from. There MUST only be one application per
origin.</p>
<p>When served as a static file, it is RECOMMENDED that the manifest be
stored with the extension <code>.webapp</code>. The manifest MUST be
served with a <code>Content-Type</code> header of
<code>application/x-web-app-manifest+json</code>. It is RECOMMENDED that
manifests be served over SSL.</p>
</section>
</section>
<section>
<h2>Application Records</h2>
<section>
<p>Applications are represented by a JavaScript object that is accessible
to web content.</p>
<dl title='interface AppObject' class='idl'>
<dt>readonly attribute DOMString origin</dt>
<dd>The origin of the application, represented by a FQDN.</dd>
<dt>readonly attribute Object manifest</dt>
<dd>A JavaScript object as returned by JSON.parse invoked on the
manifest.</dd>
<dt>readonly attribute DOMString installOrigin</dt>
<dd>The origin of the page from which the application was
installed.</dd>
<dt>readonly attribute unsigned long installTime</dt>
<dd>Time in milliseconds since epoch at which the application was
installed.</dd>
<dt>readonly attribute Object parameters</dt>
<dd>Parameters that were provided at install time.</dd>
<dt>EventTarget launch()</dt>
<dd>Launches this application (behaviour is runtime dependent).</dd>
<dt>EventTarget uninstall()</dt>
<dd>Uninstalls this application. <em>This call is available to
privileged callers only.</em></dd>
</dl>
</section>
</section>
<section>
<h2>Application Registry</h2>
<section>
<p>The following interface is made available to allow installation of apps
and for apps to query for their current state.</p>
<dl title='interface AppRegistry : Navigator' class='idl'>
<dt>EventTarget install(in DOMString manifestUrl, [Optional] in Object
parameters)</dt>
<dd>Triggers the installation of an application as specified by the
manifest at <code>manifestUrl</code>. The User-Agent must fetch the
manifest from the provided URL, verify that it is valid, and then ask
for permission from the user to allow installation to proceed. The
User-Agent must also persist the parameters provided (if any) which may
later be retrived from the <code>AppObject</code> representing this
application. The user may choose to whitelist certain origins to allow
them to install applications without any permission prompts.</dd>
<dt>EventTarget getSelf()</dt>
<dd>Retrieves the application record for the origin at which the call
is made.</dd>
<dt>EventTarget getInstalled()</dt>
<dd>Retrieves application records for all apps that have been installed
so far from the origin at which the call is made.</dd>
<dt>attribute AppRegistryManagement mgmt</dt>
<dd>Provides access to the management interace. <em>This attribute is
available to privileged callers only.</em></dd>
</dl>
</section>
</section>
<section>
<h2>Application Registry Management</h2>
<section>
<p>A privileged caller is a web page that has been explicitely authorized
by the user to manage applications on their behalf. Such privileged
origins also have access to the AppRegistryManagement interface as
described below.</p>
<dl title='interface AppRegistryManagement' class='idl'>
<dt>EventTarget getAll()</dt>
<dd>Retrieves the application records for all apps that have been
installed so far.</dd>
<dt>attribute EventListener oninstall</dt>
<dd>This value may be set to a function that will be invoked when an
application is installed. The only argument to this function will be
the <code>AppObject</code> of the application that was installed.</dd>
<dt>attribute EventListener onuninstall</dt>
<dd>This value may be set to a function that will be invoked when an
application is uninstalled. The only argument to this function be the
<code>AppObject</code> of the application that was uninstalled.</dd>
</dl>
</section>
</section>
<section>
<h2>Application Events</h2>
<section>
<p>Most of the methods described above return an <code>EventTarget</code>
object to which success and error handlers may be attached using standard
DOM methods like <code>addEventListener</code> or attributes like
<code>onsuccess</code> and <code>onerror</code>.</p>
<dl title='interface AppEventError' class='idl'>
<dt>const unsigned short PERMISSION_DENIED = 1</dt>
<dd>Installation was denied (by user or UA).</dd>
<dt>const unsigned short MANIFEST_URL_ERROR = 2</dt>
<dd>The manifest could not be found at the given location.</dd>
<dt>const unsigned short NETWORK_ERROR = 3</dt>
<dd>The manifest could not fetched from the given location at this
time.</dd>
<dt>const unsigned short MANIFEST_PARSE_ERROR = 4</dt>
<dd>The manifest could not be parsed.</dd>
<dt>const unsigned short INVALID_MANIFEST = 5</dt>
<dd>The manifest was able to be parsed but contains invalid
values.</dd>
<dt>readonly attribute short code</dt>
<dd>This value is set to one of the constants defined in this
interface.</dd>
</dl>
<dl title='interface AppEventTarget : EventTarget' class='idl'>
<dt>attribute EventListener onsuccess</dt>
<dd>May be set to a success handler.</dd>
<dt>attribute EventListener onerror</dt>
<dd>May be set to an error handler.</dd>
<dt>void addEventListener(DOMString event, EventListener e)</dt>
<dd><code>event</code> can be either be "install" or "uninstall".</dd>
<dt>void removeEventListener(DOMString event, EventListener e)</dt>
<dd><code>event</code> can either be "install" or "uninstall".</dd>
<dt>readonly attribute Object result</dt>
<dd>The type and value of <code>result</code> depends on the operation
for which this <code>EventTarget</code> was returned. If an
<code>onerror</code> is fired, this value will be set to
<code>AppEventError</code>. When <code>getSelf()</code> and
<code>getInstalled()</code> succeed, ths value will be set to an array
of <code>AppObject</code>s.</dd>
</dl>
</section>
</section>
</body>
</html>