forked from sysapps/runtime
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
1648 lines (1403 loc) · 72.7 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
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html>
<head>
<title>Runtime and Security Model for Web Applications</title>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8'>
<script src="http://www.w3.org/Tools/respec/respec-w3c-common" class="remove"></script>
<script class='remove'>
var respecConfig = {
specStatus: "ED",
shortName: "runtime",
// TODO
//publishDate: "2012-12-12",
//previousPublishDate: "2011-06-07",
//previousMaturity: "ED",
edDraftURI: "http://sysapps.github.com/runtime/index.html",
// if this is a LCWD, uncomment and set the end of its review period
// lcEnd: "2009-08-05",
extraCSS: ["../ReSpec.js/css/respec.css"],
noIDLIn: true,
editors: [
{
name: "Mounir Lamouri",
company: "Mozilla",
companyURL: "http://mozilla.org/"
},
{
name: "金明 (Ming Jin)",
company: "Samsung Electronics, Co., Ltd",
companyURL: "http://www.samsung.com/sec"
},
],
wg: "System Applications Working Group",
wgURI: "http://www.w3.org/2012/sysapps/",
wgPublicList: "public-sysapps",
wgPatentURI: "http://www.w3.org/2004/01/pp-impl/58119/status"
};
</script>
<style>
todo { display: none; }
</style>
</head>
<body>
<section id='abstract'>
<p>This document specifies two classes of Web application: <em>hosted Web
applications</em> and <em>packaged applications</em>. These applications
differ from traditional Web applications in their life cycle, security
model, and access to APIs that are not normally available to Web
applications. Conceptually, the application manifest indicates that an
application can be "installed" on an end-user's device. What distinguishes
a traditional Web application from a hosted web application is an
application manifest: this is a JSON resource that contains application
specific metadata (e.g., the name of the application), and optionally
various security related permission requests to resources on the Web and/or
services and capabilities on the device.</p>
<figure>
<img src="images/apptypes.png" alt="">
<figcaption>
The figure shows the overlap between traditional web applications,
hosted web applications, and packaged applications. Web applications
make use of standard Web technologies but don't make use of an
application manifest. On the other hand, hosted applications make use
of an application manifest, while packaged applications have both an
application manifest and are packaged using [[!ZIP]].
</figcaption>
</figure>
<p>Installation of hosted or packaged applications onto a device can be
initiated through either linking to an application manifest or through the
use of the <code>ApplicationRegistry</code> API. This API gives a developer
a degree of control over the installation process.</p>
<p>This specification also specifies aspects related to the application's
lifecycle that are outside the control of the developer. These events
sometimes result in <em>system messages</em> being generated. Developers
can register event listeners to listen for these special events during the
life cycle of their application.</p>
</section>
<section>
<h2>Terminology</h2>
<p>A <dfn>langauge tag</dfn> is a string that matches the production of a
<code>Language-Tag</code> defined in the <a>[[!BCP47]]</a> specifications
(see the <a href=
"http://www.iana.org/assignments/language-subtag-registry">IANA Language
Subtag Registry</a> for an authoritative list of possible values, see also
the <a href=
"http://www.iso.org/iso/country_codes/iso_3166_code_lists/country_names_and_code_elements">
Maintenance Agency for ISO 3166 country codes</a>). Language tags that meet
the validity criteria of [[!RFC5646]] section 2.2.9 that can be verified
without reference to the IANA Language Subtag Registry are considered
structurally valid.</p>
<p>
The <dfn><a href="http://dev.w3.org/html5/spec/webappapis.html#event-handlers">
EventHandler</a></dfn> interface represents a callback used for event
handlers as defined in [[!HTML5]].
</p>
<!--
<p>
The concepts <dfn><a href="http://dev.w3.org/html5/spec/webappapis.html#queue-a-task">
queue a task</a></dfn> and
<dfn><a href="http://dev.w3.org/html5/spec/webappapis.html#fire-a-simple-event">
fire a simple event</a></dfn> are defined in [[!HTML5]].
</p>
-->
<p>The concept of <dfn><a href='http://dev.w3.org/html5/spec/webappapis.html#fire-a-simple-event'>
fire a simple event</a></dfn> is defined in [[!HTML5]].</p>
<p>
The terms <dfn> <a href="http://dev.w3.org/html5/spec/webappapis.html#event-handlers">
event handlers</a></dfn> and
<dfn><a href="http://dev.w3.org/html5/spec/webappapis.html#event-handler-event-type">
event handler event types</a></dfn> are defined in [[!HTML5]].
</p>
<p>The <dfn><a href='http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html/#interface-domerror'>
DOMError</a></dfn> interface represents an error handling object as
defined in [[!DOM4]].
</section>
<section>
<h2>Application Manifest</h2>
<p>An <dfn>application manifest</dfn> is a JSON file describing an
installable web application. This JSON file consists of a top-level object
and several properties. The JSON grammar is described in [[!RFC4627]].</p>
<pre class="example highlight">{
"name": "The Example App",
"description": "Exciting Open Web development action!",
"launch_path": "/",
"version": "1.0",
"icons": {
"16": "/img/icon_16.png",
"48": "/img/icon_48.png",
"128": "/img/icon_128.png"
},
"developer": {
"name": "Foo Corp.",
"url": "http://sysapps.org/example"
},
"appcache_path": "/cache.manifest",
"locales": {
"es": {
"description": "¡Acción abierta emocionante del desarrollo del Web!",
"developer": {
"url": "https://sysapps.org/example/es-ES"
}
}
},
"default_locale": "en",
"screen_size": {
"min_width": "600",
"min_height": "300"
},
"required_features": ["touch", "geolocation", "webgl"],
"permissions": {
"contacts": {
"description": "Required for auto-completion in the share screen",
"access": "read"
}
},
"fullscreen": "true",
"relNotes": {
"1.0": "Bugs fixed. New exciting effects. Ready for an official release!",
"0.5": "First alpha version with still some bugs but already fun!"
}
}</pre>
<section>
<h2>Properties</h2>
<section>
<h2>Adding new properties to the manifest</h2>
<p>Any new specification can add new properties to the <a>application
manifest</a>. Those specifications MUST describe the new properties,
the expected values and the expected behaviour. Implementations MUST
implement the basic properties as describe below but SHOULD only
implement any extented feature if they are implementing those
specifications.</p>
</section>
<section>
<h2>Basic properties</h2>
<p>All leaf properties MUST contain a string value unless specified
otherwise.</p>
<p>The following properties MUST be part of the <a>application
manifest</a>: <code>name</code> and <code>description</code>.
In addition, if <code>locales</code> is part of the <a>application
manifest</a>, <code>default_locale</code> MUST be part of the <a>
application manifest</a>. The other properties are optional.</p>
<ul class="properties">
<li><dfn id="propdef-name">name</dfn>: The name of the web application
in the default locale. The name SHOULD not be longer than 128
characters.</li>
<li><dfn id="propdef-description">description</dfn>: A short
description of the web application. The description MUST be in the
default locale. The description SHOULD not be longer than 1024
characters.</li>
<li><dfn id="propdef-default_locale">default_locale</dfn>: The
property's value MUST be the top-level name and description's locale.
</li>
<li><dfn id="propdef-launch_path">launch_path</dfn>: The property's
value MUST be the path within the <a>application's origin</a> 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. Relative URLs MUST use the <a>application manifest</a> URL as
base URL.</li>
<li>
<dfn id="propdef-developer">developer</dfn>: This property describe
the developer of the application and MUST contain the following
properties:
<ul>
<li><dfn id="propdef-developer-name">name</dfn>: The value MUST
contain the name of the developer.</li>
<li><dfn id="propdef-url">url</dfn>: The value MUST contain an URL
pointing to the developer's website</li>
</ul>
</li>
<li>
<dfn id="propdef-locales">locales</dfn>: The property's value MUST
contain a map of locale specific overrides of strings contained in
the <a>application manifest</a>. Each locale key is keyed on a
<a>language tag</a>, and contains a sparse representation of the
manifest. Any field in the <a>locales</a> property SHOULD override
the corresponding property in a localized user interface. The UA
MAY ignore some values if localizing the property doesn't appear
to be legit.<br>
If the <a>locales</a> property is set, the <a>default_locale</a>
MUST also be set.
</li>
<!-- Commented because it is a controversial feature.
<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 value MUST
contain the absolute path to the application cache manifest
[[!OFFLINE-WEBAPPS]].<br>
When an application is installed, the AppCache manifest will be
fetched and parsed, and its static assets under the CACHE header
MUST be cached.
</li>
<li><dfn id="propdef-version">version</dfn>: The value MUST be a
string that represents the version of the application. The UA SHOULD
NOT interpret this value but MAY show it to the user so the auther
SHOULD use human understandable versions.</dfn>
<li><dfn id="propdef-screen_size">screen_size</dfn>: This object
SHOULD 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. Those values are only
hint for the UA and should not be considered as mandatory
restrictions.</li>
<li><dfn id="propdef-required_features">required_features</dfn>: This
value MUST be an array containing the mandatory feature set the
application needs in order to run correctly. If the property is
missing or the value is an empty array or if the value is invalid, the
mandatory feature set SHOULD be considered as the empty set.<br>
<span style='color: red;'>TBD: add a list of features.</span></li>
<!-- Commented because it might hopefully go to the Screen Orientation API spec.
<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-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-relnotes'>relNotes</dfn>: This property's value
MUST contain a map associating an application's version with a string
describing the changes between that version and the previous one.</li>
<li><dfn id="propdef-permisssions">permissions</dfn>: This value
consists of a set of permissions that the application needs. An
application SHOULD list every API that is considered to require user
permission in this field. Usage of an API without a corresponding
entry in the manifest SHOULD 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>
<p>Each specification MUST specify the new permissions that would be
required to use the feature it is defining.</p>
</li>
<!-- Commented because it should go to the Web Intents/Web Activities spec.
<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>
<p>The <dfn>application's origin</dfn> is the origin of the <a>application
manifest</a>. [[!ORIGIN]]</p>
</section>
</section>
<section>
<h2>Serving Manifests</h2>
<p>An <a>application manifest</a> MUST be served from the same origin as
the application.</p>
<p>When served as a static file, it is RECOMMENDED that the manifest is
stored with the extension <code>.webapp</code>. The manifest MUST be
served with a <i>Content-Type</i> header of
<code>application/x-web-app-manifest+json</code>. It is RECOMMENDED that
<a>application manifests</a> are served over SSL.</p>
</section>
</section>
<section>
<h2>Application Management</h2>
<section>
<h2><a>Application</a> interface</h2>
<section>
<p>Web Applications are represented by the <a>Application</a>
interface.</p>
<dl title='interface Application' class='idl'>
<dt>readonly attribute DOMString origin</dt>
<dd>The attribute MUST return the <a>application's origin</a>.</dd>
<dt>readonly attribute Object manifest</dt>
<dd>The attribute MUST return an object representing the parsed
<a>application manifest</a>.</dd>
<dt>readonly attribute DOMString installOrigin</dt>
<dd>The attribute MUST return the origin of the page from which the
application was installed. [[!ORIGIN]]</dd>
<dt>readonly attribute unsigned long installTime</dt>
<dd>The attribute MUST return the time in milliseconds since epoch
at which the application was installed.</dd>
<dt>readonly attribute Object parameters</dt>
<dd>The attribute MUST return the parameters that were provided
at install time. See <code>install()</code> in
<a>ApplicationRegistry</a>.</dd>
<dt><a>DOMRequest</a> launch()</dt>
<dd>This method MUST return a <a>DOMRequest</a> instance and then run the following steps asynchronously:
<ol>
<li>If the caller isn't allowed by the UA to launch the
application, the UA MUST fire an <code>error</code> event
to the <a>DOMRequest</a> object with the
<code>"NotAllowedError"</code> error code and exit those
steps.</li>
<li>If the caller is allowed to launch the application, the
UA SHOULD launch the application.</li>
<li>If the application has been successfuly launched, the UA
MUST fire a <code>success</code> event to the
<a>DOMRequest</a> object and set <code>result</code> to
null.<br>
Otherwise, the UA MUST fire an <code>error</code> event
to the <a>DOMRequest</a> object with an error code that
describes the error.</li>
</ol>
</dd>
<dt><a>DOMRequest</a> uninstall()</dt>
<dd>This method MUST return a <a>DOMRequest</a> instance and then run the following steps asynchronously:
<ol>
<li>If the application isn't currently installed, the UA MUST
fire an <code>error</code> event to the <a>DOMRequest</a>
object with the <code>"NotInstalledError"</code> error code
and exit those steps.</li>
<li>If the caller isn't allowed by the UA to uninstall the
application, the UA MUST fire an <code>error</code> event
to the <a>DOMRequest</a> object with the
<code>"NotAllowedError"</code> error code and exit those
steps.</li>
<li>If the caller is allowed to uninstall the application,
the UA SHOULD uninstall the application.</li>
<li>If the application has been successfuly uninstalled, the
UA MUST fire a <code>success</code> event to the
<a>DOMRequest</a> object and set <code>result</code> to
null.<br>
Otherwise, the UA MUST fire an <code>error</code> event
to the <a>DOMRequest</a> object with an error code that
describes the error.</li>
</ol>
</dd>
<!-- Update-related API -->
<dt>readonly attribute DOMString updateState</dt>
<dd>The attribute MUST return the empty string,
<code>available</code>, <code>downloading</code>,
<code>downloaded</code> or <code>installing</code>, depending on the
state of the application.<br>
If the application is being updated, the attribute MUST return
<code>installing</code>.<br>
If the application is ready to be updated, with the updtade fully
downloaded or if there is no download to proceed to the update, the
attribute MUST return <code>downloaded</code>.<br>
If the application's update is being downloaded, the attribute MUST
return <code>downloading</code>.<br>
If there is an application update available, it is not being
installed, nor downloaded, nor downloading, the attribute MUST
return <code>available</code>.
Otherwise, the attribute MUST return the empty string.</dd>
<dt>readonly attribute unsigned long downloadSize</dt>
<dd>The attribute SHOULD return the size of the download that would be
required to update the application in kilobytes, if any. If the
application doesn't have have an available update, if the download
has already been done or if the UA can't find out the size of the
download required for the update, the attribute MUST return 0.<br>
If the download is happening, the attribute MUST return 0.<br>
If the download has been made but interupted and the UA is able to
continue it, the attribute SHOULD return the remaining size to
download.</dd>
<dt>DownloadRequest downloadUpdate()</dt>
<dd>The method MUST return a <a>DownloadRequest</a> object and
asynchronously run the following steps:
<ol>
<li>If the application doesn't have an available update, the UA
MUST send an <a>error message</a> to the request object with the
value <code>InvalidState</code> and abort these steps.</li>
<li>If the application doesn't require a download to process the
update, the UA MUST send a <a>succes message</a> to the request
object with no value and abort these steps.</li>
<li>If the application's update is currently being downloaded, the
request MUST reflect the current state of the download. Otherwise,
the request must <a>start the download</a>.</li>
</ol>
</dd>
<!-- Execution states related API -->
<dt>readonly attribute DOMString state;</dt>
<dd>The attribute MUST return <code>running</code> if the
current application state is <a>running</a>. Otherwise, if the
current application state is <a>paused</a>, it MUST return
<code>paused</code>. Otherwise, it MUST return
<code>terminated</code>.</dd>
<dt>void hide()</dt>
<dd>When this method is called, the UA SHOULD hide the application
from the user. Hiding the application SHOULD fire visibility events
as described in [[!PAGE-VISIBILITY]].<br>
If the application was already not visible, this method MUST be a
no-op.</dd>
<dt>void exit()</dt>
<dd>When this method is called, the UA MUST put the application
state to <a>terminated</a> and fire the appropriate events.<br>
If the application was already in the <a>terminated</a> state, this
method MUST be a no-op.</dd>
<dt>attribute EventHandler onlaunch</dt>
<dd></dd>
<dt>attribute EventHandler onpause</dt>
<dd></dd>
<dt>attribute EventHandler onresume</dt>
<dd></dd>
<dt>attribute EventHandler onterminate</dt>
<dd></dd>
</dl>
</section>
<p>The following are the <a>event handlers</a> (and their
corresponding <a>event handler event types</a>) that MUST be supported
as attributes by the <code>Application</code> objects:</p>
<table class="simple">
<thead>
<tr>
<th>event handler</th>
<th>event handler event type</th>
</tr>
</thead>
<tbody>
<tr>
<td><strong><code>onlaunch</code></strong></td>
<td><code>launch</code></td>
</tr>
<tr>
<td><strong><code>onpause</code></strong></td>
<td><code>pause</code></td>
</tr>
<tr>
<td><strong><code>onresume</code></strong></td>
<td><code>resume</code></td>
</tr>
<tr>
<td><strong><code>onterminate</code></strong></td>
<td><code>terminate</code></td>
</tr>
</tbody>
</table>
</section>
<section>
<h2><a>DownloadRequest</a> interface</h2>
<section>
<dl title='interface DownloadRequest : DOMRequest' class='idl'>
<dt>void cancel()</dt>
<dd>This method MUST stops the download and asynchronously send an
<a>error message</a> to itself with the value
<code>UserCancel</code>.</dd>
<dt>attribute double progress</dt>
<dd>If the current state is <code>error</code> the attribute MUST
return 0.0. Otherwise, if the current state is <code>success</code>,
the attribute MUST return 1.0. Otherwise, the attribute SHOULD
return the current progress of the download expressed between 0.0
and 1.0.</dd>
<dt>attribute EventHandler onprogress</dt>
</dl>
<p>When the caller <dfn>start the download</dfn>, the
<a>DownloadRequest</a> SHOULD start downloading the resource.</p>
<p>If the resource fails to download, the UA MUST send an <a>error
message</a> to the request.<br>
<p>If the resource succeed to download, the UA MUST send a <a>success
message</a> to the request.</p>
<p>While the resource is downloading, which means as long as
<code>readyState</code> is <code>pending</code>, the UA SHOULD
regularly <a>fire a simple event</a> named <a>progress</a> on the
object. The UA should note that sending too much events might have an
impact on performance but sending too few of them might impact the
user experince.</p>
<p>The following are the <a>event handlers</a> (and their
corresponding <a>event handler event types</a>) that MUST be supported
as attributes by the <code>DOMRequest</code> objects:</p>
<table class="simple">
<thead>
<tr>
<th>event handler</th>
<th>event handler event type</th>
</tr>
</thead>
<tbody>
<tr>
<td><strong><code>onprogress</code></strong></td>
<td><code>progress</code></td>
</tr>
</tbody>
</table>
</section>
</section>
<section>
<h2>Extension to the <a>Navigator</a> interface</h2>
<section>
<p>An <a>ApplicationRegistry</a> instance is exposed on the
<code>Navigator</code> object trough the an <code>app</code>
attribute.</p>
<dl title='partial interface Navigator' class='idl'>
<dt>readonly attribute ApplicationRegistry app</dt>
<dd>The attribute MUST return an <a>ApplicationRegistry</a> instance.</dd>
</dl>
</section>
</section>
<section>
<h2><a>ApplicationRegistry</a> interface</h2>
<section>
<p>The <a>ApplicationRegistry</a> interface allows handling
applications and query there status.</p>
<dl title='interface ApplicationRegistry' class='idl'>
<dt>DOMRequest install(in DOMString manifestUrl, [Optional] in Object
parameters)</dt>
<dd>This method MUST return a <a>DOMRequest</a> instance and then run the following steps asynchronously:
<ol>
<li>If the caller isn't allowed by the UA to install the
application, the UA MUST fire an <code>error</code> event
to the <a>DOMRequest</a> object with the
<code>"NotAllowedError"</code> error code and exit those
steps.</li>
<li>If the caller is allowed to install the application, the
UA SHOULD install the application as described in the
manifest at <code>manifestUrl</code>.</li>
<li>If the application has been successfuly installed, the UA
MUST fire a <code>success</code> event to the
<a>DOMRequest</a> object and set <code>result</code> to
null.<br>
Otherwise, the UA MUST fire an <code>error</code> event
to the <a>DOMRequest</a> object with an error code that
describes the error.</li>
</ol>
<p>The UA SHOULD verify at any moment before installing that
<code>manifestUrl</code> points to a valid manifest. If this is
not the case, the UA MUST fire an <code>error</code> event to
the <a>DOMRequest</a> object with the
<code>"InvalidArgumentError"</code> and exit the steps.</p>
<p>The UA SHOULD save the <code>parameters</code> if some are
passed so they can later be retrieved by the
<code>parameters</code> attribute on the <a>Application</a>
interface.</p>
</dd>
<dt>DOMRequest getSelf()</dt>
<dd>The UA SHOULD return a <a>DOMRequest</a> object and
asynchronously get all applications that have an origin matching
the caller's origin. [[!ORIGIN]]<br>
When those applications are collected, the UA SHOULD send a
<code>success</code> event to the <a>DOMRequest</a> object and
populate its <code>request</code> attribute with an array of
<a>Application</a> objects representing the applications.</dd>
<dt>DOMRequest getInstalled()</dt>
<dd>The UA SHOULD return a <a>DOMRequest</a> object and
asynchronously get all applications that have an origin matching
the caller's origin. [[!ORIGIN]]<br>
When those applications are collected, the UA SHOULD send a
<code>success</code> event to the <a>DOMRequest</a> object and
populate its <code>request</code> attribute with an array of
<a>Application</a> objects representing the applications.</dd>
<dt>DOMRequest checkInstalled(DOMString manifestURL)</dt>
<dd>The UA SHOULD return a <a>DOMRequest</a> object and
asynchronously check if there is an installed application in the
system with a manifest URL matching <i>manifestURL</i>.<br>
After the asynchronous operation is done,, the IA SHOULD send a
<code>success</code> event to the <a>DOMRequest</a> object and
populate its <code>result</code> attribute with the boolean value
true if there is an installed application fulfilling the condition,
otherwise <code>result</code> should be set to false.</dd>
<todo>
checkInstalled() could be synchronous. Seems way more convevient.
</todo>
<todo>
<ul>
<li>What's the real difference between getSelf() and getInstalled()?</li>
<li>Can an application be not installed but still in the registry? How?</li>
</ul>
</todo>
<dt>attribute ApplicationManagement management</dt>
<dd>If the caller isn't allowed to manage applications, the UA MUST
return null. Otherwise, it MUST return an
<a>ApplicationManagement</a> object.</dd>
<todo>
<ul>
<li>Permission check isn't clearly defined here. Should it be better?</li>
</ul>
</todo>
</dl>
</section>
</section>
<section>
<h2><a>ApplicationManagement</a> interface</h2>
<section>
<p>The <a>ApplicationManagement</a> interface allows access to all
applications and is being informed any time an application is being
installed or uninstalled. The intent of this interface is to be
restricted to privileged callers.</p>
<dl title='interface ApplicationManagement' class='idl'>
<dt class='no-docs'>
DOMRequest getAll()
</dt>
<dd></dd>
<dt class='no-docs'>
DOMRequest applyUpdate(Application application)
</dt>
<dd></dd>
<dt class='no-docs'>attribute EventHandler oninstall</dt>
<dd></dd>
<dt class='no-docs'>attribute EventHandler onuninstall</dt>
<dd></dd>
</dl>
<p>The <code>getAll</code> method SHOULD return a <a>DOMRequest</a>
object and asynchronously get all applications currently in the
application registry.<br>
When those applications are collected, the UA SHOULD send a
<code>success</code> event to the <a>DOMRequest</a> object and
populate its <code>request</code> attribute with an array of
<a>Application</a> objects representing the applications.</p>
the applications.</p>
<p>The <code>applyUpdate</code> method MUST return a <a>DOMRequest</a>
object and perform the following steps asynchronously:
<ol>
<li>If the application doesn't have an updated or the updated
isn't fully downloaded, the UA MUST send an <a>error message</a>
to the request with the value <code>InvalidState</code> and abort
these steps.</li>
<li>Stop <i>application</i> from running if it is currently
running.</li>
<li>Replace the previous version with the new version of the
application.</li>
<li>If an error has occured during the previous steps, the UA MUST
send an <a>error message</a> to the request with any appropriate
value. Otherwise, the UA MUST send a <a>success message</a> to the
request with an <a>Application</a> object representing the updated
application as a value.</li>
</ol>
</p>
</section>
<section>
<h2>Events</h2>
<p>
An <a>install</a> event using the <a>ApplicationEvent</a> interface
MUST be fired on all <a>ApplicationManagement</a> instances as soon
as an application is installed with the <code>application</code>
attribute set to the <a>Application</a> object representing the
installed application.
</p>
<p>
The <a>uninstall</a> event using the <a>ApplicationEvent</a>
interface MUST be fired on all <a>ApplicationManagement</a>
instances as soon as an application is uninstalled with the
<code>application</code> attribute set to the <a>Application</a>
object representing the uninstalled application.
</p>
<p>
The following are the <a>event handlers</a> (and their corresponding
<a>event handler event types</a>) that MUST be supported as
attributes by the <code>ApplicationManagement</code> object:
</p>
<table class="simple">
<thead>
<tr>
<th>event handler</th>
<th>event handler event type</th>
</tr>
</thead>
<tbody>
<tr>
<td><strong><code>oninstall</code></strong></td>
<td><code>install</code></td>
</tr>
<tr>
<td><strong><code>onuninstall</code></strong></td>
<td><code>uninstall</code></td>
</tr>
</tbody>
</table>
</section>
</section>
<section>
<h2>Application Event Types</h2>
<p>Application Events are sent when an event happen on the application
level like an application being installed or uninstalled.</p>
<section>
<dl title='[Constructor(DOMString type, Application eventInitDict)]
interface ApplicationEvent : Event' class='idl'>
<dt>readonly attribute Application application</dt>
<dd></dd>
</dl>
<dl title='dictionary ApplicationEventInit : EventInit' class='idl'>
<dt>Application application</dt>
<dd></dd>
</dl>
</section>
<p><a>ApplicationEvent</a> objects MUST contain a non-null <code>application</code>
attribute representing the application on each the action happened.<br>
The application events are always sent asynchronously, do not buble and
are not cancelable.</p>
<p>
There are currently two types of Application Events:
<ul>
<li><dfn>install</dfn> is sent when an application is installed.
<code>application</code> MUST represent the installed application.</li>
<li><dfn>uninstall</dfn> is sent when an application is uninstalled.
<code>application</code> MUST represent the uninstalled application.</li>
</ul>
</p>
</section>
</section>
<section>
<h2>Packaged applications</h2>
<p>A <dfn>packaged application</dfn> is an application that is
self-contained in a container. All resources that are commonly used by the
application SHOULD be available in the container.</p>
<p>A <dfn>hosted application</dfn> is an application that is not a
<a>packaged application</a></p>
<section class="informative">
<h2>Use cases</h2>
<p>A <a>packaged application</a> would be useful in a few situations,
amongst them:
<ul>
<li>If a marketplace wants to guarantee that an application is safe,
it allows it to review the application codes and makes sure that all
permissions granted can't be used outside of the reviewed code. In
addition, it forces, by design, that any update will go trough the
same review process.</li>
<li>Some developers might want to develop for the Web Platform without
investing in a server infrastructure. Any client-side only
applications written on top of the Web Platform will be able to be
very easily distributed that way.</li>
</ul></p>
</section>
<section>
<h2>Package format</h2>
<p>An <a>application manifest</a> for the application MUST be present at
the root of the container.</p>
<p>The container of a <a>packaged application</a> MUST be a ZIP file.</p>
</section>
<section>
<h2>URI of a packaged file</h2>
<p>A file contained in a <a>packaged application</a> MUST have an URI
with the following rules:
<ul>
<li>The <code>scheme</code> of the URI MUST be <i>app</i>.</li>
<li>The <code>authority</code> of the URI MUST be an identifier unique
for each applications. That means, two files from different
applications can't share the same <code>authority</code> but two files