discovery-api/Overview.src.html
changeset 239 7e34654692fc
parent 238 65e14f8dc95d
child 240 4bb39c70f008
     1.1 --- a/discovery-api/Overview.src.html	Tue Oct 02 14:51:33 2012 +0200
     1.2 +++ b/discovery-api/Overview.src.html	Tue Oct 02 16:32:06 2012 +0200
     1.3 @@ -1,10 +1,39 @@
     1.4  <!DOCTYPE html>
     1.5 +<!--
     1.6 +
     1.7 +  THIS IS THE WORKING VERSION OF THE CURRENT SPECIFICATION!
     1.8 +
     1.9 +  This specification is built using ReSpec.js <http://dev.w3.org/2009/dap/ReSpec.js/documentation.html>
    1.10 +
    1.11 +  From time to time it's necessary to HTML5 Tidy this document using the tool @ <http://w3c.github.com/tidy-html5/>.
    1.12 +
    1.13 +  The command used to format this document (Overview.src.html) is as follows (replacing all = signs with - signs!):
    1.14 +
    1.15 +  @> tidy ==new-blocklevel-tags section ==char-encoding utf8 ==tidy-mark no ==indent yes ==indent-spaces 2 ==indent-attributes yes ==wrap 120 ==fix-bad-comments yes -m Overview.src.html
    1.16 +
    1.17 +  To publish a new compiled version (Overview.html), we need to open this file (Overview.src.html) in any web browser.
    1.18 +  Once it has loaded we press 'Ctrl + Shift + S' (or 'Cmd' + 'Shift' + 'S' on Mac) and then select
    1.19 +  'Save as HTML (Source)' from the resulting menu.
    1.20 +
    1.21 +  We then replace Overview.html with the produced HTML source of this process.
    1.22 +
    1.23 +  Next we run HTML5 Tidy over our new Overview.html file with the following command (replacing all = signs with - signs!):
    1.24 +
    1.25 +  @> tidy ==new-blocklevel-tags section ==char-encoding utf8 ==tidy-mark no ==indent yes ==indent-spaces 2 ==indent-attributes yes ==wrap 120 ==hide-comments yes -m Overview.html
    1.26 +
    1.27 +  Now the specification is ready to be published :)
    1.28 +
    1.29 +-->
    1.30  <html>
    1.31    <head>
    1.32 -    <title>Networked Service Discovery and Messaging</title>
    1.33 -    <meta http-equiv='Content-Type' content='text/html;charset=utf-8'/>
    1.34 -    <script type="text/javascript" class='remove'>
    1.35 -      var respecConfig = {
    1.36 +    <title>
    1.37 +      Network Service Discovery
    1.38 +    </title>
    1.39 +    <meta http-equiv='Content-Type'
    1.40 +          content='text/html; charset=utf-8'>
    1.41 +    <script type="text/javascript"
    1.42 +          class='remove'>
    1.43 +var respecConfig = {
    1.44            specStatus:   "ED",
    1.45            //publishDate:  "2012-08-22",
    1.46            shortName:    "discovery-api",
    1.47 @@ -32,10 +61,13 @@
    1.48            wgPatentURI:  "http://www.w3.org/2004/01/pp-impl/43696/status"
    1.49        };
    1.50      </script>
    1.51 -
    1.52 -    <script src='http://www.w3.org/Tools/respec/respec-w3c-common' type="text/javascript" class='remove' async></script>
    1.53 +    <script src='http://www.w3.org/Tools/respec/respec-w3c-common'
    1.54 +          type="text/javascript"
    1.55 +          class='remove'
    1.56 +          async="">
    1.57 +</script>
    1.58      <style type="text/css">
    1.59 -      /* Custom CSS optimizations (Richard Tibbett) */
    1.60 +/* Custom ReSpec CSS (by Rich Tibbett) */
    1.61  
    1.62        /* Add better spacing to sections */
    1.63        section, .section { margin-bottom: 2em; }
    1.64 @@ -67,187 +99,212 @@
    1.65        table td, table th { border-left:solid; border-right:solid; border-bottom:solid thin; vertical-align:top; padding:0.2em }
    1.66      </style>
    1.67    </head>
    1.68 -
    1.69    <body>
    1.70      <section id='abstract'>
    1.71        <p>
    1.72 -        This specification defines a mechanism for an HTML document to discover and subsequently communicate with <abbr title="Hypertext Transfer Protocol">HTTP</abbr>-based services
    1.73 -        advertised via common discovery protocols within a user's network.
    1.74 +        This specification defines a mechanism for an HTML document to discover and subsequently communicate with
    1.75 +        <abbr title="Hypertext Transfer Protocol">HTTP</abbr>-based services advertised via common discovery protocols
    1.76 +        within the current network.
    1.77        </p>
    1.78      </section>
    1.79 -
    1.80      <section id='sotd'>
    1.81        <p>
    1.82 -        This document represents the early consensus of the group on the scope and features of the proposed
    1.83 -        API.
    1.84 +        This document represents the early consensus of the group on the scope and features of the proposed API.
    1.85        </p>
    1.86      </section>
    1.87 -
    1.88      <section class="informative">
    1.89 -      <h3>Introduction</h3>
    1.90 -
    1.91 -      <p>To enable Web pages to connect and communicate with Local-networked Services provided over HTTP, this specification introduces the
    1.92 -      <a href="#navigatornetworkservice"><code>NavigatorNetworkService</code></a> interface.</p>
    1.93 -
    1.94 +      <h3>
    1.95 +        Introduction
    1.96 +      </h3>
    1.97        <p>
    1.98 -         Using this <abbr title="Application Programming Interface">API</abbr> consists of requesting a well-known service type, known by developers and advertised by Local-networked Devices. User authorization, where the user connects the web page to one or more discovered services,
    1.99 -         is expected before the web page is able to interact with any Local-networked Services.
   1.100 +        To enable Web pages to connect and communicate with Local-networked Services provided over HTTP, this
   1.101 +        specification introduces the <a href="#navigatornetworkservice"><code>NavigatorNetworkService</code></a>
   1.102 +        interface.
   1.103        </p>
   1.104 -
   1.105        <p>
   1.106 -         A web page creates a request to obtain connectivity to services running in the network by specifying a well-known discovery service type that it wishes to interact with.
   1.107 +        Using this <abbr title="Application Programming Interface">API</abbr> consists of requesting a well-known
   1.108 +        service type, known by developers and advertised by Local-networked Devices. User authorization, where the user
   1.109 +        connects the web page to one or more discovered services, is expected before the web page is able to interact
   1.110 +        with any Local-networked Services.
   1.111        </p>
   1.112 -
   1.113        <p>
   1.114 -         The user agent, having captured all advertised services on the network from the Service Discovery mechanisms included in this recommendation, attempts to match
   1.115 -      the requested service type to a discovered service according to the processing described herein.
   1.116 +        A web page creates a request to obtain connectivity to services running in the network by specifying a
   1.117 +        well-known discovery service type that it wishes to interact with.
   1.118        </p>
   1.119 -
   1.120        <p>
   1.121 -          If a service connectivity request is successful then the Web page is provided with the necessary information to communicate with the authorized Local-networked Service.
   1.122 -          If the request fails then the Web page will receive an error callback containing an error code describing the cause of Local-networked Service connectivity failure.
   1.123 +        The user agent, having captured all advertised services on the network from the Service Discovery mechanisms
   1.124 +        included in this recommendation, attempts to match the requested service type to a discovered service according
   1.125 +        to the processing described herein.
   1.126        </p>
   1.127 -
   1.128        <p>
   1.129 -         Once connected to a Local-networked Service the Web page can send requests and receive responses to the Local-networked Service via the messaging format and appropriate channel inferred from the service type
   1.130 -         authorized via the provided API.
   1.131 -         The Web page, once connected, can also receive service-pushed events, in the messaging format supported by the Local-networked Device, if such event subscription functionality is provided by the
   1.132 -         connected Local-networked Service.
   1.133 +        If a service connectivity request is successful then the Web page is provided with the necessary information to
   1.134 +        communicate with the authorized Local-networked Service. If the request fails then the Web page will receive an
   1.135 +        error callback containing an error code describing the cause of Local-networked Service connectivity failure.
   1.136        </p>
   1.137 -
   1.138 +      <p>
   1.139 +        Once connected to a Local-networked Service the Web page can send requests and receive responses to the
   1.140 +        Local-networked Service via the messaging format and appropriate channel inferred from the service type
   1.141 +        authorized via the provided API. The Web page, once connected, can also receive service-pushed events, in the
   1.142 +        messaging format supported by the Local-networked Device, if such event subscription functionality is provided
   1.143 +        by the connected Local-networked Service.
   1.144 +      </p>
   1.145        <div class="example">
   1.146 -       <p>Example of requesting a DNS-SD advertised service:</p>
   1.147 -       <hr />
   1.148 -       <pre class="highlight">function showServices( services ) {
   1.149 +        <p>
   1.150 +          Example of requesting a DNS-SD advertised service:
   1.151 +        </p>
   1.152 +        <hr>
   1.153 +        <pre class="highlight">
   1.154 +function showServices( services ) {
   1.155    // Show a list of all the services provided to the web page
   1.156 -  for(var i = 0, l = services.length; i < l; i++) console.log( services[i].name );
   1.157 +  for(var i = 0, l = services.length; i &lt; l; i++) console.log( services[i].name );
   1.158  }
   1.159  
   1.160 -navigator.getNetworkServices('zeroconf:_boxee-jsonrpc._tcp', showServices);</pre>
   1.161 +navigator.getNetworkServices('zeroconf:_boxee-jsonrpc._tcp', showServices);
   1.162 +</pre>
   1.163        </div>
   1.164 -
   1.165        <div class="example">
   1.166 -        <p>Example of requesting a UPnP advertised service, also handling error conditions:</p>
   1.167 -        <hr />
   1.168 -        <pre class="highlight">function showServices( services ) {
   1.169 +        <p>
   1.170 +          Example of requesting a UPnP advertised service, also handling error conditions:
   1.171 +        </p>
   1.172 +        <hr>
   1.173 +        <pre class="highlight">
   1.174 +function showServices( services ) {
   1.175    // Show a list of all the services provided to the web page
   1.176 -  for(var i = 0, l = services.length; i < l; i++) console.log( services[i].name );
   1.177 +  for(var i = 0, l = services.length; i &lt; l; i++) console.log( services[i].name );
   1.178  }
   1.179  
   1.180  function error( e ) {
   1.181    console.log( "Error occurred: " + e.code );
   1.182  }
   1.183  
   1.184 -navigator.getNetworkServices('upnp:urn:schemas-upnp-org:service:ContentDirectory:1', showServices, error);</pre>
   1.185 +navigator.getNetworkServices('upnp:urn:schemas-upnp-org:service:ContentDirectory:1', showServices, error);
   1.186 +</pre>
   1.187        </div>
   1.188 -
   1.189        <div class="example">
   1.190 -        <p>Example of requesting either a DNS-SD or UPnP advertised service:</p>
   1.191 -        <hr />
   1.192 -        <pre class="highlight">function showServices( services ) {
   1.193 +        <p>
   1.194 +          Example of requesting either a DNS-SD or UPnP advertised service:
   1.195 +        </p>
   1.196 +        <hr>
   1.197 +        <pre class="highlight">
   1.198 +function showServices( services ) {
   1.199    // Show a list of all the services provided to the web page (+ service type)
   1.200 -  for(var i = 0, l = services.length; i < l; i++)
   1.201 +  for(var i = 0, l = services.length; i &lt; l; i++)
   1.202       console.log( services[i].name + '(' + services[i].type + ')' );
   1.203  }
   1.204  
   1.205  navigator.getNetworkServices([
   1.206    'zeroconf:_boxee-jsonrpc._tcp',
   1.207    'upnp:urn:schemas-upnp-org:service:ContentDirectory:1'
   1.208 -], showServices);</pre>
   1.209 +], showServices);
   1.210 +</pre>
   1.211        </div>
   1.212 -
   1.213 -      <p>For more detailed examples see the <a href="#examples">Examples</a> section.
   1.214 +      <p>
   1.215 +        For more detailed examples see the <a href="#examples">Examples</a> section.
   1.216 +      </p>
   1.217      </section>
   1.218 -
   1.219 -    <section
   1.220 -     id='conformance'>
   1.221 -
   1.222 -     <p>Requirements phrased in the imperative as part of algorithms (such as "strip any leading space characters" or "return false and abort these steps") are to be interpreted with the
   1.223 -     meaning of the key word ("must", "should", "may", etc) used in introducing the algorithm.</p>
   1.224 -
   1.225 -     <p>
   1.226 -      Some conformance requirements are phrased as requirements on attributes, methods or objects. Such requirements are to be interpreted as requirements on user agents.
   1.227 -     </p>
   1.228 -
   1.229 -     <p>
   1.230 -      Conformance requirements phrased as algorithms or specific steps <em class="ct">MAY</em> be implemented in any manner, so long as the end result is equivalent. (In particular, the algorithms defined in
   1.231 -      this specification are intended to be easy to follow, and not intended to be performant.)
   1.232 -     </p>
   1.233 -
   1.234 -     <p>
   1.235 -      The only conformance class defined by this specification is a <dfn>user agent</dfn>.
   1.236 -     </p>
   1.237 -
   1.238 -     <p>
   1.239 -      User agents <em class="ct">MAY</em> impose implementation-specific limits on otherwise unconstrained inputs, e.g. to prevent denial of service attacks, to guard against running out of memory, or to work
   1.240 -      around platform-specific limitations.
   1.241 -     </p>
   1.242 -
   1.243 -     <p>
   1.244 -      When support for a feature is disabled (e.g. as an emergency measure to mitigate a security problem, or to aid in development, or for performance reasons), user agents <em class="ct">MUST</em> act as if
   1.245 -      they had no support for the feature whatsoever, and as if the feature was not mentioned in this specification. For example, if a particular feature is accessed via an attribute in a Web
   1.246 -      IDL interface, the attribute itself would be omitted from the objects that implement that interface - leaving the attribute on the object but making it return null or throw an exception
   1.247 -      is insufficient.
   1.248 -     </p>
   1.249 -
   1.250 +    <section id='conformance'>
   1.251 +      <p>
   1.252 +        Requirements phrased in the imperative as part of algorithms (such as "strip any leading space characters" or
   1.253 +        "return false and abort these steps") are to be interpreted with the meaning of the key word ("must", "should",
   1.254 +        "may", etc) used in introducing the algorithm.
   1.255 +      </p>
   1.256 +      <p>
   1.257 +        Some conformance requirements are phrased as requirements on attributes, methods or objects. Such requirements
   1.258 +        are to be interpreted as requirements on user agents.
   1.259 +      </p>
   1.260 +      <p>
   1.261 +        Conformance requirements phrased as algorithms or specific steps <em class="ct">MAY</em> be implemented in any
   1.262 +        manner, so long as the end result is equivalent. (In particular, the algorithms defined in this specification
   1.263 +        are intended to be easy to follow, and not intended to be performant.)
   1.264 +      </p>
   1.265 +      <p>
   1.266 +        The only conformance class defined by this specification is a <dfn>user agent</dfn>.
   1.267 +      </p>
   1.268 +      <p>
   1.269 +        User agents <em class="ct">MAY</em> impose implementation-specific limits on otherwise unconstrained inputs,
   1.270 +        e.g. to prevent denial of service attacks, to guard against running out of memory, or to work around
   1.271 +        platform-specific limitations.
   1.272 +      </p>
   1.273 +      <p>
   1.274 +        When support for a feature is disabled (e.g. as an emergency measure to mitigate a security problem, or to aid
   1.275 +        in development, or for performance reasons), user agents <em class="ct">MUST</em> act as if they had no support
   1.276 +        for the feature whatsoever, and as if the feature was not mentioned in this specification. For example, if a
   1.277 +        particular feature is accessed via an attribute in a Web IDL interface, the attribute itself would be omitted
   1.278 +        from the objects that implement that interface - leaving the attribute on the object but making it return null
   1.279 +        or throw an exception is insufficient.
   1.280 +      </p>
   1.281        <section>
   1.282 -         <h3>Dependencies</h3>
   1.283 -
   1.284 -         This specification relies on several other underlying specifications.
   1.285 -
   1.286 -         <dl>
   1.287 -            <dt>HTML</dt>
   1.288 -            <dd>Many fundamental concepts from HTML are used by this specification. [[!HTML5]]</dd>
   1.289 -            <dt>WebIDL</dt>
   1.290 -            <dd>The IDL blocks in this specification use the semantics of the WebIDL specification. [[!WEBIDL]]</dd>
   1.291 -         </dl>
   1.292 +        <h3>
   1.293 +          Dependencies
   1.294 +        </h3>This specification relies on several other underlying specifications.
   1.295 +        <dl>
   1.296 +          <dt>
   1.297 +            HTML
   1.298 +          </dt>
   1.299 +          <dd>
   1.300 +            Many fundamental concepts from HTML are used by this specification. [[!HTML5]]
   1.301 +          </dd>
   1.302 +          <dt>
   1.303 +            WebIDL
   1.304 +          </dt>
   1.305 +          <dd>
   1.306 +            The IDL blocks in this specification use the semantics of the WebIDL specification. [[!WEBIDL]]
   1.307 +          </dd>
   1.308 +        </dl>
   1.309        </section>
   1.310      </section>
   1.311 -
   1.312      <section>
   1.313 -      <h3>Terminology</h3>
   1.314 -
   1.315 +      <h3>
   1.316 +        Terminology
   1.317 +      </h3>
   1.318        <p>
   1.319 -         The construction "a <code>Foo</code> object", where <code>Foo</code> is actually an interface, is sometimes used instead of the more accurate "an object implementing the interface <code>Foo</code>".
   1.320 +        The construction "a <code>Foo</code> object", where <code>Foo</code> is actually an interface, is sometimes
   1.321 +        used instead of the more accurate "an object implementing the interface <code>Foo</code>".
   1.322        </p>
   1.323 -
   1.324        <p>
   1.325 -         The term DOM is used to refer to the API set made available to scripts in Web applications, and does not necessarily imply the existence of an actual <code>Document</code> object or of any
   1.326 -         other <code>Node</code> objects as defined in the DOM Core specifications. [[!DOM4]]
   1.327 +        The term DOM is used to refer to the API set made available to scripts in Web applications, and does not
   1.328 +        necessarily imply the existence of an actual <code>Document</code> object or of any other <code>Node</code>
   1.329 +        objects as defined in the DOM Core specifications. [[!DOM4]]
   1.330        </p>
   1.331 -
   1.332        <p>
   1.333 -         An IDL attribute is said to be <em>getting</em> when its value is being retrieved (e.g. by author script), and is said to be <em>setting</em> when a new value is assigned to it.
   1.334 +        An IDL attribute is said to be <em>getting</em> when its value is being retrieved (e.g. by author script), and
   1.335 +        is said to be <em>setting</em> when a new value is assigned to it.
   1.336        </p>
   1.337 -
   1.338        <p>
   1.339 -        A <dfn>valid service type</dfn> is a string that begins with <code>upnp:</code> or <code>zeroconf:</code> followed by one or more characters in the ranges U+0021, U+0023 to U+0027, U+002A to U+002B, U+002D to U+002E, U+0030 to U+0039, U+0041 to U+005A, U+005E to U+007E.
   1.340 +        A <dfn>valid service type</dfn> is a string that begins with <code>upnp:</code> or <code>zeroconf:</code>
   1.341 +        followed by one or more characters in the ranges U+0021, U+0023 to U+0027, U+002A to U+002B, U+002D to U+002E,
   1.342 +        U+0030 to U+0039, U+0041 to U+005A, U+005E to U+007E.
   1.343        </p>
   1.344 -      <p></p>
   1.345 -
   1.346        <p>
   1.347 -        A <a>valid service type</a> provided in the <code>type</code> attribute of the <a href="#dom-navigator-getnetworkservices"><code>getNetworkServices()</code></a> method will be matched against the services currently contained in the <a>list of available service records</a> according to the algorithms defined in this specification.
   1.348 +        A <a>valid service type</a> provided in the <code>type</code> attribute of the <a href=
   1.349 +        "#dom-navigator-getnetworkservices"><code>getNetworkServices()</code></a> method will be matched against the
   1.350 +        services currently contained in the <a>list of available service records</a> according to the algorithms
   1.351 +        defined in this specification.
   1.352        </p>
   1.353 -
   1.354        <p>
   1.355 -        A <dfn>user-agent generated callback url</dfn> is a Local-network accessible URL endpoint that a <a>user agent</a> generates and maintains for receiving HTTP NOTIFY requests from UPnP Event sources. It is only required when the user agent implements UPnP Service Discovery as defined in
   1.356 -        this specification.
   1.357 +        A <dfn>user-agent generated callback url</dfn> is a Local-network accessible URL endpoint that a <a>user
   1.358 +        agent</a> generates and maintains for receiving HTTP NOTIFY requests from UPnP Event sources. It is only
   1.359 +        required when the user agent implements UPnP Service Discovery as defined in this specification.
   1.360        </p>
   1.361 -
   1.362      </section>
   1.363 -
   1.364      <section>
   1.365 -     <h2>Requesting networked services</h2>
   1.366 -
   1.367 -
   1.368 -<pre class="widl">[Supplemental, NoInterfaceObject]
   1.369 +      <h2>
   1.370 +        Requesting networked services
   1.371 +      </h2>
   1.372 +      <pre class="widl">
   1.373 +[Supplemental, NoInterfaceObject]
   1.374  interface <dfn id="navigatornetworkservice">NavigatorNetworkService</dfn> {
   1.375    // Obtain a Local-networked Service
   1.376    void <a href="#dom-navigator-getnetworkservices">getNetworkServices</a>( in any type,
   1.377 -                           in <a href="#navigatornetworkservicesuccesscallback">NavigatorNetworkServiceSuccessCallback</a> successCallback,
   1.378 -                           in optional <a href="#navigatornetworkserviceerrorcallback">NavigatorNetworkServiceErrorCallback</a> errorCallback );
   1.379 +                           in <a href=
   1.380 +"#navigatornetworkservicesuccesscallback">NavigatorNetworkServiceSuccessCallback</a> successCallback,
   1.381 +                           in optional <a href=
   1.382 +"#navigatornetworkserviceerrorcallback">NavigatorNetworkServiceErrorCallback</a> errorCallback );
   1.383  };
   1.384 -<a class="externalDFN" href="http://www.whatwg.org/specs/web-apps/current-work/complete/timers.html#navigator">Navigator</a> implements <a href="#navigatornetworkservice">NavigatorNetworkService</a>;
   1.385 +<a class="externalDFN"
   1.386 +     href=
   1.387 +     "http://www.whatwg.org/specs/web-apps/current-work/complete/timers.html#navigator">Navigator</a> implements <a href=
   1.388 +     "#navigatornetworkservice">NavigatorNetworkService</a>;
   1.389  
   1.390  [Callback=FunctionOnly, NoInterfaceObject]
   1.391  interface <dfn id="navigatornetworkservicesuccesscallback">NavigatorNetworkServiceSuccessCallback</dfn> {
   1.392 @@ -266,441 +323,453 @@
   1.393    void handleEvent( in <a href="#navigatornetworkserviceerror">NavigatorNetworkServiceError</a> error );
   1.394  };
   1.395  </pre>
   1.396 -
   1.397 -  <section>
   1.398 -   <h2>Methods</h2>
   1.399 -
   1.400 -      <dl class="domintro">
   1.401 -        <dt>
   1.402 -          <var title="">window</var>
   1.403 -           .
   1.404 -          <code title="dom-navigator">
   1.405 -            <a href="http://www.whatwg.org/specs/web-apps/current-work/complete/timers.html#navigator">navigator</a>
   1.406 -          </code>
   1.407 -           .
   1.408 -          <code title="dom-navigator-getNetworkServices">
   1.409 -            <a href="#dom-navigator-getnetworkservices">getNetworkServices</a>
   1.410 -          </code>
   1.411 -          (
   1.412 -          <var title="">type</var>
   1.413 -          ,
   1.414 -          <var title="">successCallback</var>
   1.415 -           [,
   1.416 -          <var title="">errorCallback</var>
   1.417 -           ] )
   1.418 -        </dt>
   1.419 -        <dd>
   1.420 -          <p>Prompts the user to select one or more discovered network services that have advertised support for the requested service type.</p>
   1.421 +      <section>
   1.422 +        <h2>
   1.423 +          Methods
   1.424 +        </h2>
   1.425 +        <dl class="domintro">
   1.426 +          <dt>
   1.427 +            <var title="">window</var> . <code title="dom-navigator"><a href=
   1.428 +            "http://www.whatwg.org/specs/web-apps/current-work/complete/timers.html#navigator">navigator</a></code> .
   1.429 +            <code title="dom-navigator-getNetworkServices"><a href=
   1.430 +            "#dom-navigator-getnetworkservices">getNetworkServices</a></code> ( <var title="">type</var> , <var title=
   1.431 +            "">successCallback</var> [, <var title="">errorCallback</var> ] )
   1.432 +          </dt>
   1.433 +          <dd>
   1.434 +            <p>
   1.435 +              Prompts the user to select one or more discovered network services that have advertised support for the
   1.436 +              requested service type.
   1.437 +            </p>
   1.438 +            <p>
   1.439 +              The <var title="">type</var> argument contains one or more <a>valid service type</a> tokens that the web
   1.440 +              page would like to interact with.
   1.441 +            </p>
   1.442 +            <p>
   1.443 +              If the user accepts, the <var title="">successCallback</var> is invoked, with one or more <code><a href=
   1.444 +              "#networkservice"><code>NetworkService</code></a></code> objects as its argument.
   1.445 +            </p>
   1.446 +            <p>
   1.447 +              If the user declines, the <var title="">errorCallback</var> (if any) is invoked.
   1.448 +            </p>
   1.449 +          </dd>
   1.450 +        </dl>
   1.451 +        <div>
   1.452            <p>
   1.453 -            The
   1.454 -            <var title="">type</var>
   1.455 -             argument contains one or more <a>valid service type</a> tokens that the web page would like to interact with.
   1.456 +            When the <dfn id="dom-navigator-getnetworkservices"
   1.457 +               title="dom-navigator-getnetworkservices"><code>getNetworkServices(type, successCallback[,
   1.458 +               errorCallback])</code></dfn> method is called, the <a>user agent</a> <em class="ct">MUST</em> run the
   1.459 +               following steps:
   1.460            </p>
   1.461 -          <p>
   1.462 -            If the user accepts, the
   1.463 -            <var title="">successCallback</var>
   1.464 -             is
   1.465 -          invoked, with one or more
   1.466 -            <code>
   1.467 -              <a href="#networkservice"><code>NetworkService</code></a>
   1.468 -            </code>
   1.469 -             objects as
   1.470 -          its argument.
   1.471 -          </p>
   1.472 -          <p>
   1.473 -            If the user declines, the
   1.474 -            <var title="">errorCallback</var>
   1.475 -             (if
   1.476 -          any) is invoked.
   1.477 -          </p>
   1.478 -        </dd>
   1.479 -      </dl>
   1.480 -
   1.481 -       <div>
   1.482 -          <p>
   1.483 -            When the <dfn id="dom-navigator-getnetworkservices" title="dom-navigator-getnetworkservices"><code>getNetworkServices(type, successCallback[, errorCallback])</code></dfn> method is called, the <a>user agent</a> <em class="ct">MUST</em> run the following steps:
   1.484 -          </p>
   1.485 -
   1.486            <ol class="rule">
   1.487 -
   1.488 +            <li>Let <var>requested control types</var> be initially set to an empty array.
   1.489 +            </li>
   1.490 +            <li>If <var>type</var> is an array consisting of one or more <a>valid service type</a> tokens, then let
   1.491 +            <var>requested control types</var> by the value of <var>type</var>, removing any non-<a>valid service
   1.492 +            type</a> tokens from the resulting array.
   1.493 +            </li>
   1.494 +            <li>If <var>type</var> is a string consisting of one <a>valid service type</a> token, then let
   1.495 +            <var>requested control types</var> be an array containing one item with a value of <var>type</var>.
   1.496 +            </li>
   1.497 +            <li>If <var>requested control types</var> is an array that contains at least one or more <a title=
   1.498 +            "valid service type">valid service type</a> tokens then continue to the step labeled <em>process</em>
   1.499 +            below. Otherwise, the <a>user agent</a> <em class="ct">MUST</em> <a href=
   1.500 +            "http://www.whatwg.org/specs/web-apps/current-work/complete/webappapis.html#queue-a-task"
   1.501 +                  class="externalDFN">queue a task</a> to invoke <var>errorCallback</var>, if it is provided and is an
   1.502 +                  object of type <code>Function</code>, with a new <a href=
   1.503 +                  "#navigatornetworkserviceerror"><code>NavigatorNetworkServiceError</code></a> object whose <a href=
   1.504 +                  "#dom-navigatornetworkserviceerror-code"><code>code</code></a> attribute has the numeric value 2
   1.505 +                  (<a href=
   1.506 +                  "#dom-navigatornetworkserviceerror-unknown_type_prefix"><code>UNKNOWN_TYPE_PREFIX_ERR</code></a>) as
   1.507 +                  its argument, abort any remaining steps and return.
   1.508 +            </li>
   1.509              <li>
   1.510 -              Let <var>requested control types</var> be initially set to an empty array.
   1.511 +              <em>Process</em>: Let <var>services found</var> be an empty array.
   1.512              </li>
   1.513 -
   1.514 -            <li>
   1.515 -               If <var>type</var> is an array consisting of one or more <a>valid service type</a> tokens, then let <var>requested control types</var> by the value of <var>type</var>, removing any non-<a>valid service type</a> tokens from the resulting array.
   1.516 +            <li>For each <var>available service</var> in the <a>list of available service records</a> run the following
   1.517 +            steps:
   1.518 +              <ol class="rule">
   1.519 +                <li>For each <var>requested control type</var> in <var>requested control types</var>: If <var>available
   1.520 +                service</var>'s <code>type</code> attribute equals the <var>requested control type</var> then let <var>
   1.521 +                  matched service</var> equal the value of <var>available service</var> and continue at the step
   1.522 +                  labeled <var>attach</var> below.
   1.523 +                </li>
   1.524 +                <li>Continue at the next <var>available service</var>.
   1.525 +                </li>
   1.526 +                <li>
   1.527 +                  <em>Attach</em>: If <var>matched service</var> is not empty then run the following steps:
   1.528 +                  <ol class="rule">
   1.529 +                    <li>Let <var>new service object</var> be a new <a href=
   1.530 +                    "#networkservice"><code>NetworkService</code></a> object, mapping the parameters of <var>matched
   1.531 +                    service</var> to this new object where possible.
   1.532 +                    </li>
   1.533 +                    <li>Append <var>new service object</var> to the <var>services found</var> array.
   1.534 +                    </li>
   1.535 +                  </ol>
   1.536 +                </li>
   1.537 +              </ol>
   1.538              </li>
   1.539 -
   1.540 -            <li>
   1.541 -               If <var>type</var> is a string consisting of one <a>valid service type</a> token, then let <var>requested control types</var> be an array containing one item with a value of <var>type</var>.
   1.542 +            <li>If <var>services found</var> is an empty array, then the <a>user agent</a> <em class="ct">MUST</em>
   1.543 +            <a href="http://www.whatwg.org/specs/web-apps/current-work/complete/webappapis.html#queue-a-task"
   1.544 +                  class="externalDFN">queue a task</a> to invoke <var>errorCallback</var>, if it is provided and is an
   1.545 +                  object of type <code>Function</code>, with a new <a href=
   1.546 +                  "#navigatornetworkserviceerror"><code>NavigatorNetworkServiceError</code></a> object whose <a href=
   1.547 +                  "#dom-navigatornetworkserviceerror-code"><code>code</code></a> attribute has the numeric value 1
   1.548 +                  (<a href=
   1.549 +                  "#dom-navigatornetworkserviceerror-permission_denied"><code>PERMISSION_DENIED_ERR</code></a>) as its
   1.550 +                  argument, abort any remaining steps and return.
   1.551              </li>
   1.552 -
   1.553 -            <li>
   1.554 -               If <var>requested control types</var> is an array that contains at least one or more <a title="valid service type">valid service type</a> tokens then continue to the step labeled <em>process</em> below. Otherwise, the <a>user agent</a> <em class="ct">MUST</em> <a href="http://www.whatwg.org/specs/web-apps/current-work/complete/webappapis.html#queue-a-task" class="externalDFN">queue a task</a> to invoke <var>errorCallback</var>, if it is provided and is an object of type <code>Function</code>, with a new <a href="#navigatornetworkserviceerror"><code>NavigatorNetworkServiceError</code></a> object whose
   1.555 -                 <a href="#dom-navigatornetworkserviceerror-code"><code>code</code></a> attribute has the numeric value 2
   1.556 -                  (<a href="#dom-navigatornetworkserviceerror-unknown_type_prefix"><code>UNKNOWN_TYPE_PREFIX_ERR</code></a>) as its argument,
   1.557 -                   abort any remaining steps and return.
   1.558 +            <li>Return, and run the remaining steps asynchronously.
   1.559              </li>
   1.560 -
   1.561 -            <li>
   1.562 -               <em>Process</em>: Let <var>services found</var> be an empty array.
   1.563 +            <li>Optionally, e.g. based on a previously-established user preference, for security reasons, or due to
   1.564 +            platform limitations, the <a>user agent</a> <em class="ct">MAY</em> <a href=
   1.565 +            "http://www.whatwg.org/specs/web-apps/current-work/complete/webappapis.html#queue-a-task"
   1.566 +                  class="externalDFN">queue a task</a> to invoke <var>errorCallback</var>, if it is provided and is an
   1.567 +                  object of type <code>Function</code>, with a new <a href=
   1.568 +                  "#navigatornetworkserviceerror"><code>NavigatorNetworkServiceError</code></a> object whose <a href=
   1.569 +                  "#dom-navigatornetworkserviceerror-code"><code>code</code></a> attribute has the numeric value 1
   1.570 +                  (<a href=
   1.571 +                  "#dom-navigatornetworkserviceerror-permission_denied"><code>PERMISSION_DENIED_ERR</code></a>) as its
   1.572 +                  argument, abort any remaining steps and return.
   1.573              </li>
   1.574 -
   1.575 -            <li>
   1.576 -               For each <var>available service</var> in the <a>list of available service records</a> run the following steps:
   1.577 -               <ol class="rule">
   1.578 -                  <li>
   1.579 -                    For each <var>requested control type</var> in <var>requested control types</var>: If <var>available service</var>'s <code>type</code> attribute equals the <var>requested control type</var> then let <var>matched service</var> equal the value of <var>available service</var> and continue at the step labeled <var>attach</var> below.
   1.580 -                  </li>
   1.581 -                  <li>
   1.582 -                     Continue at the next <var>available service</var>.
   1.583 -                  </li>
   1.584 -                  <li>
   1.585 -                     <em>Attach</em>: If <var>matched service</var> is not empty then run the following steps:
   1.586 -
   1.587 -                     <ol class="rule">
   1.588 -                        <li>
   1.589 -                           Let <var>new service object</var> be a new <a href="#networkservice"><code>NetworkService</code></a> object, mapping the parameters of
   1.590 -                     <var>matched service</var> to this new object where possible.
   1.591 -                        </li>
   1.592 -                        <li>
   1.593 -                           Append <var>new service object</var> to the <var>services found</var> array.
   1.594 -                        </li>
   1.595 -                     </ol>
   1.596 -                  </li>
   1.597 -               </ol>
   1.598 -            </li>
   1.599 -
   1.600 -            <li>
   1.601 -               If <var>services found</var> is an empty array, then the <a>user agent</a> <em class="ct">MUST</em> <a href="http://www.whatwg.org/specs/web-apps/current-work/complete/webappapis.html#queue-a-task" class="externalDFN">queue a task</a> to invoke <var>errorCallback</var>, if it is provided and is an object of type <code>Function</code>, with a new <a href="#navigatornetworkserviceerror"><code>NavigatorNetworkServiceError</code></a> object whose
   1.602 -                 <a href="#dom-navigatornetworkserviceerror-code"><code>code</code></a> attribute has the numeric value 1
   1.603 -                 (<a href="#dom-navigatornetworkserviceerror-permission_denied"><code>PERMISSION_DENIED_ERR</code></a>) as its argument, abort any remaining steps and return.
   1.604 -            </li>
   1.605 -
   1.606 -            <li>
   1.607 -               Return, and run the remaining steps asynchronously.
   1.608 -            </li>
   1.609 -
   1.610 -            <li>
   1.611 -               Optionally, e.g. based on a previously-established user preference, for security reasons, or due to platform limitations, the <a>user agent</a> <em class="ct">MAY</em> <a href="http://www.whatwg.org/specs/web-apps/current-work/complete/webappapis.html#queue-a-task" class="externalDFN">queue a task</a> to invoke <var>errorCallback</var>, if it is provided and is an object of type <code>Function</code>, with a new <a href="#navigatornetworkserviceerror"><code>NavigatorNetworkServiceError</code></a> object whose
   1.612 -                 <a href="#dom-navigatornetworkserviceerror-code"><code>code</code></a> attribute has the numeric value 1
   1.613 -                 (<a href="#dom-navigatornetworkserviceerror-permission_denied"><code>PERMISSION_DENIED_ERR</code></a>) as its argument, abort any remaining steps and return.
   1.614 -            </li>
   1.615 -
   1.616 -            <li>
   1.617 -                  The <a>user agent</a> <em class="ct">MUST</em> prompt the user in a user-agent-specific manner for permission to provide the
   1.618 -                  <a href="http://www.whatwg.org/specs/web-apps/current-work/complete/browsers.html#entry-script" class="externalDFN">entry script</a>'s
   1.619 -                  <a href="http://www.whatwg.org/specs/web-apps/current-work/complete/origin-0.html#origin" class="externalDFN">origin</a> with an array of
   1.620 -                  <a href="#networkservice"><code>NetworkService</code></a> objects representing the user-authorized subset of <var>services found</var>.
   1.621 -
   1.622 -               <p>
   1.623 -                  If the user grants permission to access one or more networked services then the <a>user agent</a> SHOULD include an
   1.624 -                  "ongoing local-network communication" indicator.
   1.625 -               </p>
   1.626 -
   1.627 -               <p>If the user denies permission, then the <a>user agent</a> <em class="ct">MUST</em> <a href="http://www.whatwg.org/specs/web-apps/current-work/complete/webappapis.html#queue-a-task" class="externalDFN">queue a task</a> to invoke <var>errorCallback</var>, if it is provided and is an object of type <code>Function</code>, with a new <a href="#navigatornetworkserviceerror"><code>NavigatorNetworkServiceError</code></a> object whose
   1.628 -                <a href="#dom-navigatornetworkserviceerror-code"><code>code</code></a> attribute has the numeric value 1
   1.629 -                (<a href="#dom-navigatornetworkserviceerror-permission_denied"><code>PERMISSION_DENIED_ERR</code></a>) as its argument, abort any remaining steps and return.
   1.630 +            <li>The <a>user agent</a> <em class="ct">MUST</em> prompt the user in a user-agent-specific manner for
   1.631 +            permission to provide the <a href=
   1.632 +            "http://www.whatwg.org/specs/web-apps/current-work/complete/browsers.html#entry-script"
   1.633 +                  class="externalDFN">entry script</a>'s <a href=
   1.634 +                  "http://www.whatwg.org/specs/web-apps/current-work/complete/origin-0.html#origin"
   1.635 +                  class="externalDFN">origin</a> with an array of <a href=
   1.636 +                  "#networkservice"><code>NetworkService</code></a> objects representing the user-authorized subset of
   1.637 +                  <var>services found</var>.
   1.638 +              <p>
   1.639 +                If the user grants permission to access one or more networked services then the <a>user agent</a>
   1.640 +                SHOULD include an "ongoing local-network communication" indicator.
   1.641                </p>
   1.642 -
   1.643 +              <p>
   1.644 +                If the user denies permission, then the <a>user agent</a> <em class="ct">MUST</em> <a href=
   1.645 +                "http://www.whatwg.org/specs/web-apps/current-work/complete/webappapis.html#queue-a-task"
   1.646 +                   class="externalDFN">queue a task</a> to invoke <var>errorCallback</var>, if it is provided and is an
   1.647 +                   object of type <code>Function</code>, with a new <a href=
   1.648 +                   "#navigatornetworkserviceerror"><code>NavigatorNetworkServiceError</code></a> object whose <a href=
   1.649 +                   "#dom-navigatornetworkserviceerror-code"><code>code</code></a> attribute has the numeric value 1
   1.650 +                   (<a href=
   1.651 +                   "#dom-navigatornetworkserviceerror-permission_denied"><code>PERMISSION_DENIED_ERR</code></a>) as its
   1.652 +                   argument, abort any remaining steps and return.
   1.653 +              </p>
   1.654                <p>
   1.655                  If the user never responds, this algorithm stalls on this step.
   1.656                </p>
   1.657 -
   1.658              </li>
   1.659 -
   1.660 -            <li>
   1.661 -               Let <var>services</var> be the array of one or more <a href="#networkservice"><code>NetworkService</code></a> objects for which the user granted permission.
   1.662 +            <li>Let <var>services</var> be the array of one or more <a href=
   1.663 +            "#networkservice"><code>NetworkService</code></a> objects for which the user granted permission.
   1.664              </li>
   1.665 -
   1.666 -            <li>
   1.667 -               For each Object <var>service</var> in <var>services</var>, run the following substeps:
   1.668 -
   1.669 -               <ol class="rule">
   1.670 -                  <li>
   1.671 -                     Add the <var>service</var>'s <code>url</code> parameter to the <a>entry script origin's <abbr title="Uniform Resource Locator">URL</abbr> whitelist</a>.
   1.672 -                  </li>
   1.673 -                  <li>
   1.674 -                    If <var>service</var>'s <code>type</code> parameter begins with the DOMString &quot;<code>upnp:</code>&quot; and the <var>service</var>'s <code>eventsUrl</code> parameter is not empty then <a>setup a UPnP Events Subscription</a> for <var>service</var>.
   1.675 -                  </li>
   1.676 -               </ol>
   1.677 +            <li>For each Object <var>service</var> in <var>services</var>, run the following substeps:
   1.678 +              <ol class="rule">
   1.679 +                <li>Add the <var>service</var>'s <code>url</code> parameter to the <a>entry script origin's
   1.680 +                  <abbr title="Uniform Resource Locator">URL</abbr> whitelist</a>.
   1.681 +                </li>
   1.682 +                <li>If <var>service</var>'s <code>type</code> parameter begins with the DOMString "<code>upnp:</code>"
   1.683 +                and the <var>service</var>'s <code>eventsUrl</code> parameter is not empty then <a>setup a UPnP Events
   1.684 +                Subscription</a> for <var>service</var>.
   1.685 +                </li>
   1.686 +              </ol>
   1.687              </li>
   1.688 -
   1.689 -            <li>
   1.690 -               Let <var>services manager</var> be a new <a href="#networkservices"><code>NetworkServices</code></a> object.
   1.691 +            <li>Let <var>services manager</var> be a new <a href="#networkservices"><code>NetworkServices</code></a>
   1.692 +            object.
   1.693              </li>
   1.694 -
   1.695 -            <li>
   1.696 -               Set <var>services manager</var>'s <a href="#dom-networkservices-servicesavailable"><code>servicesAvailable</code></a> attribute to the number of services currently found in the <a>list of available service records</a> whose <code>type</code> property matches any of the tokens requested in <var>requested control types</var>.
   1.697 +            <li>Set <var>services manager</var>'s <a href=
   1.698 +            "#dom-networkservices-servicesavailable"><code>servicesAvailable</code></a> attribute to the number of
   1.699 +            services currently found in the <a>list of available service records</a> whose <code>type</code> property
   1.700 +            matches any of the tokens requested in <var>requested control types</var>.
   1.701              </li>
   1.702 -
   1.703 -            <li>
   1.704 -              Add the set of <var>services</var> to the <a>list of authorized service records</a> internally against the newly created <var>services manager</var> object.
   1.705 +            <li>Add the set of <var>services</var> to the <a>list of authorized service records</a> internally against
   1.706 +            the newly created <var>services manager</var> object.
   1.707              </li>
   1.708 -
   1.709 -            <li>
   1.710 -               The <a>user agent</a> <em class="ct">MUST</em> <a href="http://www.whatwg.org/specs/web-apps/current-work/complete/webappapis.html#queue-a-task" class="externalDFN">queue a task</a> to invoke <var>successCallback</var> with
   1.711 -               <var>services manager</var> as its argument.
   1.712 +            <li>The <a>user agent</a> <em class="ct">MUST</em> <a href=
   1.713 +            "http://www.whatwg.org/specs/web-apps/current-work/complete/webappapis.html#queue-a-task"
   1.714 +                  class="externalDFN">queue a task</a> to invoke <var>successCallback</var> with <var>services
   1.715 +                  manager</var> as its argument.
   1.716              </li>
   1.717 -
   1.718            </ol>
   1.719 -
   1.720            <p>
   1.721 -            The <a href="http://www.whatwg.org/specs/web-apps/current-work/complete/webappapis.html#task-source" class="externalDFN">task source</a> for these
   1.722 -            <a href="http://www.whatwg.org/specs/web-apps/current-work/complete/webappapis.html#concept-task" class="externalDFN">tasks</a> is the
   1.723 -            <a href="http://www.whatwg.org/specs/web-apps/current-work/complete/webappapis.html#user-interaction-task-source" class="externalDFN">user interaction task source</a>.
   1.724 +            The <a href="http://www.whatwg.org/specs/web-apps/current-work/complete/webappapis.html#task-source"
   1.725 +               class="externalDFN">task source</a> for these <a href=
   1.726 +               "http://www.whatwg.org/specs/web-apps/current-work/complete/webappapis.html#concept-task"
   1.727 +               class="externalDFN">tasks</a> is the <a href=
   1.728 +               "http://www.whatwg.org/specs/web-apps/current-work/complete/webappapis.html#user-interaction-task-source"
   1.729 +               class="externalDFN">user interaction task source</a>.
   1.730            </p>
   1.731 -
   1.732            <p>
   1.733 -            When a <a href="#networkservice"><code>NetworkService</code></a> object is provided to a Web page, the <a>user agent</a> <em class="ct">MUST</em> add the <code>url</code> property
   1.734 -             to the <dfn>entry script origin's URL whitelist</dfn>. This list enables the
   1.735 -            Web page to override and initiate cross-site resource requests towards these URLs, and any sub-resources of these URLs, within the current
   1.736 -            <a href="http://www.whatwg.org/specs/web-apps/current-work/complete/browsers.html#entry-script" class="externalDFN">entry script</a>'s
   1.737 -            <a href="http://www.whatwg.org/specs/web-apps/current-work/complete/origin-0.html#origin" class="externalDFN">origin</a> via various existing mechanisms (e.g. Web Sockets, Server-Sent Events,
   1.738 -            Web Messaging, XMLHttpRequest).
   1.739 -         </p>
   1.740 -
   1.741 -         <p>
   1.742 -            If the user navigates away from the current browsing context, the <a>user agent</a> <em class="ct">MUST</em> remove all previously whitelisted urls from the <a>entry script origin's URL whitelist</a>.
   1.743 -            There is no persistence to network service selections provided to a web page. It is not possible to access a previously white-listed networked service without the necessary user authorization in all of the following cases:
   1.744 -            <ul>
   1.745 -              <li>If the current script is reloaded at any point in the same or different window.</li>
   1.746 -              <li>if the current script reinvokes the <a href="#dom-navigator-getnetworkservices"><code>getNetworkServices()</code></a> method at any point in its execution.</li>
   1.747 -              <li>If the user navigates forward or back in their history to reload the current page.</li>
   1.748 -              <li>If a script is running in a different origin.</li>
   1.749 -            </ul>
   1.750 -         </p>
   1.751 -
   1.752 -      </div>
   1.753 -      </section>
   1.754 -
   1.755 -      <section>
   1.756 -         <h3>Error Handling</h3>
   1.757 -
   1.758 -      <dl class="domintro">
   1.759 -        <dt>
   1.760 -          <var title="">error</var>
   1.761 -           .
   1.762 -          <code title="dom-NavigatorNetworkServiceError-code">
   1.763 -            <a href="#dom-navigatornetworkserviceerror-code">code</a>
   1.764 -          </code>
   1.765 -        </dt>
   1.766 -        <dd>
   1.767 +            When a <a href="#networkservice"><code>NetworkService</code></a> object is provided to a Web page, the
   1.768 +            <a>user agent</a> <em class="ct">MUST</em> add the <code>url</code> property to the <dfn>entry script
   1.769 +            origin's URL whitelist</dfn>. This list enables the Web page to override and initiate cross-site resource
   1.770 +            requests towards these URLs, and any sub-resources of these URLs, within the current <a href=
   1.771 +            "http://www.whatwg.org/specs/web-apps/current-work/complete/browsers.html#entry-script"
   1.772 +               class="externalDFN">entry script</a>'s <a href=
   1.773 +               "http://www.whatwg.org/specs/web-apps/current-work/complete/origin-0.html#origin"
   1.774 +               class="externalDFN">origin</a> via various existing mechanisms (e.g. Web Sockets, Server-Sent Events,
   1.775 +               Web Messaging, XMLHttpRequest).
   1.776 +          </p>
   1.777            <p>
   1.778 -            Returns the current error's error code. At the current time, this will be <code>1</code> or <code>2</code>, for which the
   1.779 -            corresponding error constants
   1.780 -            <a href="#dom-navigatornetworkserviceerror-permission_denied"><code>PERMISSION_DENIED_ERR</code></a> and
   1.781 -            <a href="#dom-navigatornetworkserviceerror-unknown_type_prefix"><code>UNKNOWN_TYPE_PREFIX_ERR</code></a> are defined.
   1.782 +            If the user navigates away from the current browsing context, the <a>user agent</a> <em class=
   1.783 +            "ct">MUST</em> remove all previously whitelisted urls from the <a>entry script origin's URL whitelist</a>.
   1.784 +            There is no persistence to network service selections provided to a web page. It is not possible to access
   1.785 +            a previously white-listed networked service without the necessary user authorization in all of the
   1.786 +            following cases:
   1.787            </p>
   1.788 -        </dd>
   1.789 -      </dl>
   1.790 -
   1.791 -         <p>
   1.792 -            The <dfn id="dom-navigatornetworkserviceerror-code" title="dom-navigatornetworkserviceerror-code"><code>code</code></dfn> attribute of a
   1.793 -            <a href="#navigatornetworkserviceerror"><code>NavigatorNetworkServiceError</code></a> object <em class="ct">MUST</em> return the code for the error, which will be one of the following:
   1.794 -         </p>
   1.795 -
   1.796 -         <dl>
   1.797 -            <dt>
   1.798 -               <dfn id="dom-navigatornetworkserviceerror-permission_denied" title="dom-navigatornetworkserviceerror-permission_denied"><code>PERMISSION_DENIED_ERR</code></dfn> (numeric value 1)
   1.799 -            </dt>
   1.800 -            <dd>
   1.801 -               The user or user agent denied the page permission to access any services.
   1.802 -            </dd>
   1.803 -            <dt>
   1.804 -               <dfn id="dom-navigatornetworkserviceerror-unknown_type_prefix" title="dom-navigatornetworkserviceerror-unknown_type_prefix"><code>UNKNOWN_TYPE_PREFIX_ERR</code></dfn> (numeric value 2)
   1.805 -            </dt>
   1.806 -            <dd>
   1.807 -               No <a>valid service type</a> tokens were provided in the method invocation.
   1.808 -            </dd>
   1.809 -         </dl>
   1.810 -
   1.811 -      </section>
   1.812 -
   1.813 +          <ul>
   1.814 +            <li>If the current script is reloaded at any point in the same or different window.
   1.815 +            </li>
   1.816 +            <li>if the current script reinvokes the <a href=
   1.817 +            "#dom-navigator-getnetworkservices"><code>getNetworkServices()</code></a> method at any point in its
   1.818 +            execution.
   1.819 +            </li>
   1.820 +            <li>If the user navigates forward or back in their history to reload the current page.
   1.821 +            </li>
   1.822 +            <li>If a script is running in a different origin.
   1.823 +            </li>
   1.824 +          </ul>
   1.825 +        </div>
   1.826        </section>
   1.827        <section>
   1.828 -      <h2>Obtaining networked services</h2>
   1.829 -
   1.830 +        <h3>
   1.831 +          Error Handling
   1.832 +        </h3>
   1.833 +        <dl class="domintro">
   1.834 +          <dt>
   1.835 +            <var title="">error</var> . <code title="dom-NavigatorNetworkServiceError-code"><a href=
   1.836 +            "#dom-navigatornetworkserviceerror-code">code</a></code>
   1.837 +          </dt>
   1.838 +          <dd>
   1.839 +            <p>
   1.840 +              Returns the current error's error code. At the current time, this will be <code>1</code> or
   1.841 +              <code>2</code>, for which the corresponding error constants <a href=
   1.842 +              "#dom-navigatornetworkserviceerror-permission_denied"><code>PERMISSION_DENIED_ERR</code></a> and <a href=
   1.843 +              "#dom-navigatornetworkserviceerror-unknown_type_prefix"><code>UNKNOWN_TYPE_PREFIX_ERR</code></a> are
   1.844 +              defined.
   1.845 +            </p>
   1.846 +          </dd>
   1.847 +        </dl>
   1.848 +        <p>
   1.849 +          The <dfn id="dom-navigatornetworkserviceerror-code"
   1.850 +             title="dom-navigatornetworkserviceerror-code"><code>code</code></dfn> attribute of a <a href=
   1.851 +             "#navigatornetworkserviceerror"><code>NavigatorNetworkServiceError</code></a> object <em class=
   1.852 +             "ct">MUST</em> return the code for the error, which will be one of the following:
   1.853 +        </p>
   1.854 +        <dl>
   1.855 +          <dt>
   1.856 +            <dfn id="dom-navigatornetworkserviceerror-permission_denied"
   1.857 +                title="dom-navigatornetworkserviceerror-permission_denied"><code>PERMISSION_DENIED_ERR</code></dfn>
   1.858 +                (numeric value 1)
   1.859 +          </dt>
   1.860 +          <dd>
   1.861 +            The user or user agent denied the page permission to access any services.
   1.862 +          </dd>
   1.863 +          <dt>
   1.864 +            <dfn id="dom-navigatornetworkserviceerror-unknown_type_prefix"
   1.865 +                title="dom-navigatornetworkserviceerror-unknown_type_prefix"><code>UNKNOWN_TYPE_PREFIX_ERR</code></dfn>
   1.866 +                (numeric value 2)
   1.867 +          </dt>
   1.868 +          <dd>
   1.869 +            No <a>valid service type</a> tokens were provided in the method invocation.
   1.870 +          </dd>
   1.871 +        </dl>
   1.872 +      </section>
   1.873 +    </section>
   1.874 +    <section>
   1.875 +      <h2>
   1.876 +        Obtaining networked services
   1.877 +      </h2>
   1.878        <p>
   1.879 -         The <a href="#networkservices"><code>NetworkServices</code></a> interface is the top-level response object from a call to <a href="#dom-navigator-getnetworkservices"><code>getNetworkServices()</code></a> and provides access to a set of user-authorized <a href="#networkservice"><code>NetworkService</code></a> objects for the given request.
   1.880 +        The <a href="#networkservices"><code>NetworkServices</code></a> interface is the top-level response object from
   1.881 +        a call to <a href="#dom-navigator-getnetworkservices"><code>getNetworkServices()</code></a> and provides access
   1.882 +        to a set of user-authorized <a href="#networkservice"><code>NetworkService</code></a> objects for the given
   1.883 +        request.
   1.884        </p>
   1.885 -
   1.886 -<pre class="widl">
   1.887 +      <pre class="widl">
   1.888  [NoInterfaceObject]
   1.889  interface <dfn id="networkservices">NetworkServices</dfn> {
   1.890    readonly attribute unsigned long    <a href="#dom-networkservices-length">length</a>;
   1.891    getter <a href="#networkservice">NetworkService</a> (unsigned long index);
   1.892 -  <a href="#networkservice">NetworkService</a>? <a href="#dom-networkservices-getservicebyid">getServiceById</a>(DOMString id);
   1.893 +  <a href="#networkservice">NetworkService</a>? <a href=
   1.894 +"#dom-networkservices-getservicebyid">getServiceById</a>(DOMString id);
   1.895  
   1.896    readonly attribute unsigned long    <a href="#dom-networkservices-servicesavailable">servicesAvailable</a>;
   1.897  
   1.898    // event handler attributes
   1.899 -           attribute <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/webappapis.html#eventhandler" class="externalDFN">EventHandler</a>     <a href="#dom-networkservices-onserviceavailable">onserviceavailable</a>;
   1.900 -           attribute <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/webappapis.html#eventhandler" class="externalDFN">EventHandler</a>     <a href="#dom-networkservices-onserviceunavailable">onserviceunavailable</a>;
   1.901 +           attribute <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/webappapis.html#eventhandler"
   1.902 +     class="externalDFN">EventHandler</a>     <a href="#dom-networkservices-onserviceavailable">onserviceavailable</a>;
   1.903 +           attribute <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/webappapis.html#eventhandler"
   1.904 +     class="externalDFN">EventHandler</a>     <a href=
   1.905 +     "#dom-networkservices-onserviceunavailable">onserviceunavailable</a>;
   1.906  
   1.907  };
   1.908  
   1.909 -<a href="#networkservices">NetworkServices</a> implements <a href="http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#interface-eventtarget" class="externalDFN">EventTarget</a>;
   1.910 +<a href="#networkservices">NetworkServices</a> implements <a href=
   1.911 +"http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#interface-eventtarget"
   1.912 +     class="externalDFN">EventTarget</a>;
   1.913  </pre>
   1.914 -
   1.915        <section>
   1.916 -      <h2>Attributes</h2>
   1.917 -
   1.918 +        <h2>
   1.919 +          Attributes
   1.920 +        </h2>
   1.921          <dl class="domintro">
   1.922            <dt>
   1.923 -            <code title="dom-networkservices-length">
   1.924 -              <a href="#dom-networkservices-length">length</a>
   1.925 -            </code>
   1.926 +            <code title="dom-networkservices-length"><a href="#dom-networkservices-length">length</a></code>
   1.927            </dt>
   1.928            <dd>
   1.929              <p>
   1.930 -              Returns the current number of services belonging in the respective object's <a>list of authorized service records</a>.
   1.931 +              Returns the current number of services belonging in the respective object's <a>list of authorized service
   1.932 +              records</a>.
   1.933              </p>
   1.934            </dd>
   1.935            <dt>
   1.936 -            <code title="dom-networkservices-servicesavailable">
   1.937 -              <a href="#dom-networkservices-servicesavailable">servicesAvailable</a>
   1.938 -            </code>
   1.939 +            <code title="dom-networkservices-servicesavailable"><a href=
   1.940 +            "#dom-networkservices-servicesavailable">servicesAvailable</a></code>
   1.941            </dt>
   1.942            <dd>
   1.943              <p>
   1.944 -              Returns the current number of services matching one of the app-requested <a>valid service type</a> tokens in the
   1.945 -              <a>list of available service records</a>.
   1.946 +              Returns the current number of services matching one of the app-requested <a>valid service type</a> tokens
   1.947 +              in the <a>list of available service records</a>.
   1.948              </p>
   1.949            </dd>
   1.950          </dl>
   1.951 -
   1.952          <div>
   1.953 -           <p>
   1.954 -              The <dfn id="dom-networkservices-length"><code>length</code></dfn> attribute <em class="ct">MUST</em> return the number of services represented in the object's corresponding <a>list of authorized service records</a> at the time of getting.
   1.955 -           </p>
   1.956 -
   1.957 -           <p>
   1.958 -              The <dfn id="dom-networkservices-servicesavailable"><code>servicesAvailable</code></dfn> attribute <em class="ct">MUST</em> return the number of services in the <a>list of available service records</a> whose <code>type</code> attribute matches any of the <a>valid service type</a> tokens that was initially used to create the current <a href="#networkservices"><code>NetworkServices</code></a> object.
   1.959 -           </p>
   1.960 -
   1.961 +          <p>
   1.962 +            The <dfn id="dom-networkservices-length"><code>length</code></dfn> attribute <em class="ct">MUST</em>
   1.963 +            return the number of services represented in the object's corresponding <a>list of authorized service
   1.964 +            records</a> at the time of getting.
   1.965 +          </p>
   1.966 +          <p>
   1.967 +            The <dfn id="dom-networkservices-servicesavailable"><code>servicesAvailable</code></dfn> attribute
   1.968 +            <em class="ct">MUST</em> return the number of services in the <a>list of available service records</a>
   1.969 +            whose <code>type</code> attribute matches any of the <a>valid service type</a> tokens that was initially
   1.970 +            used to create the current <a href="#networkservices"><code>NetworkServices</code></a> object.
   1.971 +          </p>
   1.972          </div>
   1.973 -
   1.974        </section>
   1.975 -
   1.976        <section>
   1.977 -      <h2>Methods</h2>
   1.978 +        <h2>
   1.979 +          Methods
   1.980 +        </h2>
   1.981          <dl class="domintro">
   1.982 -        <dt>
   1.983 -          <code title="networkservices-getter">
   1.984 -            <a href="#networkservices">services</a>
   1.985 -          </code>
   1.986 -          [
   1.987 -          <var title="">index</var>
   1.988 -          ]
   1.989 -        </dt>
   1.990 -        <dd>
   1.991 -          <p>
   1.992 -            Returns the specified <a href="#networkservice"><code>NetworkService</code></a> object.
   1.993 -          </p>
   1.994 -        </dd>
   1.995 -        <dt>
   1.996 -          <code title="networkservices-getter">
   1.997 -            <a href="#networkservices">services</a>
   1.998 -          </code>
   1.999 -          .
  1.1000 -          <code title="dom-networkservices-getservicebyid">
  1.1001 -            <a href="#dom-networkservices-getservicebyid">getServiceById</a>
  1.1002 -          </code>
  1.1003 -          (
  1.1004 -          <var title="">id</var>
  1.1005 -          )
  1.1006 -        </dt>
  1.1007 -        <dd>
  1.1008 -          <p>
  1.1009 -            Returns the <a href="#networkservice"><code>NetworkService</code></a> object with the given identifier, or null if no
  1.1010 -            service has that identifier.
  1.1011 -          </p>
  1.1012 -        </dd>
  1.1013 -      </dl>
  1.1014 -
  1.1015 -      <p>
  1.1016 -        A <a href="#networkservices"><code>NetworkServices</code></a> object represents the current list of one or more current authorized services - the <a>list of authorized service records</a>. Each item in the <a>list of authorized service records</a> is represented by a <a href="#networkservice"><code>NetworkService</code></a> object. The <a>list of authorized service records</a> is <span>immutable</span> meaning that it cannot be modified for the lifetime of a <a href="#networkservices"><code>NetworkServices</code></a> object.
  1.1017 -      </p>
  1.1018 -
  1.1019 -      <p class="note">
  1.1020 -        Each service in a <a href="#networkservices"><code>NetworkServices</code></a> object thus has an index; the first has the index 0, and each subsequent service is numbered one higher than the previous one.
  1.1021 -      </p>
  1.1022 -
  1.1023 -      <p>
  1.1024 -        The <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/infrastructure.html#supported-property-indices" class="externalDFN">supported property indices</a> of <a href="#networkservices"><code>NetworkServices</code></a> objects at any instant are the numbers from zero to the number of items in the <a>list of authorized service records</a> represented by the respective object minus one, if any services are represented in the <a>list of authorized service records</a>.
  1.1025 -      </p>
  1.1026 -
  1.1027 -      <p>
  1.1028 -        To <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/infrastructure.html#determine-the-value-of-an-indexed-property" class="externalDFN">determine the value of an indexed property</a> for a given index <var>index</var> in a <a href="#networkservices"><code>NetworkServices</code></a> object's <a>list of authorized service records</a>, the user agent <em class="ct">MUST</em> return the <a href="#networkservice"><code>NetworkService</code></a> object that represents the <var>index</var>th service in the <a>list of authorized service records</a>.
  1.1029 -      </p>
  1.1030 -
  1.1031 -      <p>
  1.1032 -        The <dfn id="dom-networkservices-getservicebyid"><code>getServiceById(id)</code></dfn> method <em class="ct">MUST</em> return the first <a href="#networkservice"><code>NetworkService</code></a> object in the <a>list of authorized service records</a> represented by the respective object whose <a href="#dom-networkservice-id"><code>id</code></a> attribute is equal to the value of the <var>id</var> argument.
  1.1033 -        When no services in the <a>list of authorized service records</a> match the given argument, the method <em class="ct">MUST</em> return null.
  1.1034 -      </p>
  1.1035 -
  1.1036 -      <p>
  1.1037 -         Services available within the local network can connect and disconnect at different times during the execution of a web page. A <a>user agent</a> can
  1.1038 -         inform a web page when the state of networked services matching the requested <a>valid service type</a> change. Web pages can use this information to enable in-page experiences for communicating the state of networked services
  1.1039 -         with the ability to change the particular service or set of services the page is connected to by re-invoking the <a href="#dom-navigator-getnetworkservices"><code>getNetworkServices()</code></a> method.
  1.1040 -      </p>
  1.1041 -
  1.1042 +          <dt>
  1.1043 +            <code title="networkservices-getter"><a href="#networkservices">services</a></code> [ <var title=
  1.1044 +            "">index</var> ]
  1.1045 +          </dt>
  1.1046 +          <dd>
  1.1047 +            <p>
  1.1048 +              Returns the specified <a href="#networkservice"><code>NetworkService</code></a> object.
  1.1049 +            </p>
  1.1050 +          </dd>
  1.1051 +          <dt>
  1.1052 +            <code title="networkservices-getter"><a href="#networkservices">services</a></code> . <code title=
  1.1053 +            "dom-networkservices-getservicebyid"><a href=
  1.1054 +            "#dom-networkservices-getservicebyid">getServiceById</a></code> ( <var title="">id</var> )
  1.1055 +          </dt>
  1.1056 +          <dd>
  1.1057 +            <p>
  1.1058 +              Returns the <a href="#networkservice"><code>NetworkService</code></a> object with the given identifier,
  1.1059 +              or null if no service has that identifier.
  1.1060 +            </p>
  1.1061 +          </dd>
  1.1062 +        </dl>
  1.1063 +        <p>
  1.1064 +          A <a href="#networkservices"><code>NetworkServices</code></a> object represents the current list of one or
  1.1065 +          more current authorized services - the <a>list of authorized service records</a>. Each item in the <a>list of
  1.1066 +          authorized service records</a> is represented by a <a href="#networkservice"><code>NetworkService</code></a>
  1.1067 +          object. The <a>list of authorized service records</a> is <span>immutable</span> meaning that it cannot be
  1.1068 +          modified for the lifetime of a <a href="#networkservices"><code>NetworkServices</code></a> object.
  1.1069 +        </p>
  1.1070 +        <p class="note">
  1.1071 +          Each service in a <a href="#networkservices"><code>NetworkServices</code></a> object thus has an index; the
  1.1072 +          first has the index 0, and each subsequent service is numbered one higher than the previous one.
  1.1073 +        </p>
  1.1074 +        <p>
  1.1075 +          The <a href=
  1.1076 +          "http://www.whatwg.org/specs/web-apps/current-work/multipage/infrastructure.html#supported-property-indices"
  1.1077 +             class="externalDFN">supported property indices</a> of <a href=
  1.1078 +             "#networkservices"><code>NetworkServices</code></a> objects at any instant are the numbers from zero to
  1.1079 +             the number of items in the <a>list of authorized service records</a> represented by the respective object
  1.1080 +             minus one, if any services are represented in the <a>list of authorized service records</a>.
  1.1081 +        </p>
  1.1082 +        <p>
  1.1083 +          To <a href=
  1.1084 +          "http://www.whatwg.org/specs/web-apps/current-work/multipage/infrastructure.html#determine-the-value-of-an-indexed-property"
  1.1085 +             class="externalDFN">determine the value of an indexed property</a> for a given index <var>index</var> in a
  1.1086 +             <a href="#networkservices"><code>NetworkServices</code></a> object's <a>list of authorized service
  1.1087 +             records</a>, the user agent <em class="ct">MUST</em> return the <a href=
  1.1088 +             "#networkservice"><code>NetworkService</code></a> object that represents the <var>index</var>th service in
  1.1089 +             the <a>list of authorized service records</a>.
  1.1090 +        </p>
  1.1091 +        <p>
  1.1092 +          The <dfn id="dom-networkservices-getservicebyid"><code>getServiceById(id)</code></dfn> method <em class=
  1.1093 +          "ct">MUST</em> return the first <a href="#networkservice"><code>NetworkService</code></a> object in the
  1.1094 +          <a>list of authorized service records</a> represented by the respective object whose <a href=
  1.1095 +          "#dom-networkservice-id"><code>id</code></a> attribute is equal to the value of the <var>id</var> argument.
  1.1096 +          When no services in the <a>list of authorized service records</a> match the given argument, the method
  1.1097 +          <em class="ct">MUST</em> return null.
  1.1098 +        </p>
  1.1099 +        <p>
  1.1100 +          Services available within the local network can connect and disconnect at different times during the
  1.1101 +          execution of a web page. A <a>user agent</a> can inform a web page when the state of networked services
  1.1102 +          matching the requested <a>valid service type</a> change. Web pages can use this information to enable in-page
  1.1103 +          experiences for communicating the state of networked services with the ability to change the particular
  1.1104 +          service or set of services the page is connected to by re-invoking the <a href=
  1.1105 +          "#dom-navigator-getnetworkservices"><code>getNetworkServices()</code></a> method.
  1.1106 +        </p>
  1.1107        </section>
  1.1108 -
  1.1109        <section>
  1.1110 -      <h2>Events</h2>
  1.1111 -
  1.1112 -      <p>
  1.1113 -         The following are the event handlers (and their corresponding event handler event types) that <em class="ct">MUST</em> be supported, as IDL attributes, by all objects implementing the <a href="#networkservices"><code>NetworkServices</code></a> interface:
  1.1114 -       </p>
  1.1115 -
  1.1116 -       <table border="1">
  1.1117 -        <thead>
  1.1118 -          <tr>
  1.1119 -            <th>
  1.1120 -              <span title="event handlers">Event handler</span>
  1.1121 -            </th>
  1.1122 -            <th>
  1.1123 -              <span>Event handler event type</span>
  1.1124 -            </th>
  1.1125 -          </tr>
  1.1126 -        </thead>
  1.1127 -        <tbody>
  1.1128 -          <tr>
  1.1129 -            <td>
  1.1130 -              <dfn id="dom-networkservices-onserviceavailable" title="dom-NetworkServices-onserviceavailable">
  1.1131 -                <code>onserviceavailable</code>
  1.1132 -              </dfn>
  1.1133 -            </td>
  1.1134 -            <td>
  1.1135 -              <a href="#event-serviceavailable"><code>serviceavailable</code>
  1.1136 -            </td>
  1.1137 -          </tr>
  1.1138 -          <tr>
  1.1139 -            <td>
  1.1140 -              <dfn id="dom-networkservices-onserviceunavailable" title="dom-NetworkServices-onserviceunavailable">
  1.1141 -                <code>onserviceunavailable</code>
  1.1142 -              </dfn>
  1.1143 -            </td>
  1.1144 -            <td>
  1.1145 -              <a href="#event-serviceunavailable"><code>serviceunavailable</code></a>
  1.1146 -            </td>
  1.1147 -          </tr>
  1.1148 -        </tbody>
  1.1149 -      </table>
  1.1150 -
  1.1151 +        <h2>
  1.1152 +          Events
  1.1153 +        </h2>
  1.1154 +        <p>
  1.1155 +          The following are the event handlers (and their corresponding event handler event types) that <em class=
  1.1156 +          "ct">MUST</em> be supported, as IDL attributes, by all objects implementing the <a href=
  1.1157 +          "#networkservices"><code>NetworkServices</code></a> interface:
  1.1158 +        </p>
  1.1159 +        <table border="1"
  1.1160 +               summary="Event handlers for NetworkServices objects">
  1.1161 +          <thead>
  1.1162 +            <tr>
  1.1163 +              <th>
  1.1164 +                <span title="event handlers">Event handler</span>
  1.1165 +              </th>
  1.1166 +              <th>
  1.1167 +                <span>Event handler event type</span>
  1.1168 +              </th>
  1.1169 +            </tr>
  1.1170 +          </thead>
  1.1171 +          <tbody>
  1.1172 +            <tr>
  1.1173 +              <td>
  1.1174 +                <dfn id="dom-networkservices-onserviceavailable"
  1.1175 +                    title="dom-NetworkServices-onserviceavailable"><code>onserviceavailable</code></dfn>
  1.1176 +              </td>
  1.1177 +              <td>
  1.1178 +                <a href="#event-serviceavailable"><code>serviceavailable</code></a>
  1.1179 +              </td>
  1.1180 +            </tr>
  1.1181 +            <tr>
  1.1182 +              <td>
  1.1183 +                <dfn id="dom-networkservices-onserviceunavailable"
  1.1184 +                    title="dom-NetworkServices-onserviceunavailable"><code>onserviceunavailable</code></dfn>
  1.1185 +              </td>
  1.1186 +              <td>
  1.1187 +                <a href="#event-serviceunavailable"><code>serviceunavailable</code></a>
  1.1188 +              </td>
  1.1189 +            </tr>
  1.1190 +          </tbody>
  1.1191 +        </table>
  1.1192        </section>
  1.1193 -
  1.1194      </section>
  1.1195      <section>
  1.1196 -    <h2>Communicating with a networked service</h3>
  1.1197 -
  1.1198 -<p>
  1.1199 -   The <a href="#networkservice"><code>NetworkService</code></a> interface is used to provide a set of connection information for an HTTP service endpoint and if available, service events, running on a networked device.
  1.1200 -</p>
  1.1201 -
  1.1202 -<pre class="widl">
  1.1203 +      <h2>
  1.1204 +        Communicating with a networked service
  1.1205 +      </h2>
  1.1206 +      <p>
  1.1207 +        The <a href="#networkservice"><code>NetworkService</code></a> interface is used to provide a set of connection
  1.1208 +        information for an HTTP service endpoint and if available, service events, running on a networked device.
  1.1209 +      </p>
  1.1210 +      <pre class="widl">
  1.1211  [NoInterfaceObject]
  1.1212  interface <dfn id="networkservice">NetworkService</dfn> {
  1.1213    readonly attribute DOMString        <a href="#dom-networkservice-id">id</a>;
  1.1214 @@ -712,713 +781,686 @@
  1.1215    readonly attribute boolean          <a href="#dom-networkservice-online">online</a>;
  1.1216  
  1.1217    // event handler attributes
  1.1218 -           attribute <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/webappapis.html#eventhandler" class="externalDFN">EventHandler</a>     <a href="#dom-networkservice-onserviceonline">onserviceonline</a>;
  1.1219 -           attribute <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/webappapis.html#eventhandler" class="externalDFN">EventHandler</a>     <a href="#dom-networkservice-onserviceoffline">onserviceoffline</a>;
  1.1220 +           attribute <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/webappapis.html#eventhandler"
  1.1221 +     class="externalDFN">EventHandler</a>     <a href="#dom-networkservice-onserviceonline">onserviceonline</a>;
  1.1222 +           attribute <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/webappapis.html#eventhandler"
  1.1223 +     class="externalDFN">EventHandler</a>     <a href="#dom-networkservice-onserviceoffline">onserviceoffline</a>;
  1.1224  
  1.1225 -           attribute <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/webappapis.html#eventhandler" class="externalDFN">EventHandler</a>     <a href="#dom-networkservice-onnotify">onnotify</a>;
  1.1226 +           attribute <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/webappapis.html#eventhandler"
  1.1227 +     class="externalDFN">EventHandler</a>     <a href="#dom-networkservice-onnotify">onnotify</a>;
  1.1228  };
  1.1229  
  1.1230 -<a href="#networkservice">NetworkService</a> implements <a href="http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#interface-eventtarget" class="externalDFN">EventTarget</a>;
  1.1231 +<a href="#networkservice">NetworkService</a> implements <a href=
  1.1232 +"http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#interface-eventtarget"
  1.1233 +     class="externalDFN">EventTarget</a>;
  1.1234  </pre>
  1.1235 -
  1.1236 -<section>
  1.1237 -  <h2>Attributes</h2>
  1.1238 -
  1.1239 -      <dl class="domintro">
  1.1240 -        <dt>
  1.1241 -          <var title="">service</var>
  1.1242 -           .
  1.1243 -          <code title="dom-networkservice-id">
  1.1244 -            <a href="#dom-networkservice-id">id</a>
  1.1245 -          </code>
  1.1246 -        </dt>
  1.1247 -        <dd>
  1.1248 +      <section>
  1.1249 +        <h2>
  1.1250 +          Attributes
  1.1251 +        </h2>
  1.1252 +        <dl class="domintro">
  1.1253 +          <dt>
  1.1254 +            <var title="">service</var> . <code title="dom-networkservice-id"><a href=
  1.1255 +            "#dom-networkservice-id">id</a></code>
  1.1256 +          </dt>
  1.1257 +          <dd>
  1.1258 +            <p>
  1.1259 +              A unique identifier for the given user-selected service instance.
  1.1260 +            </p>
  1.1261 +          </dd>
  1.1262 +          <dt>
  1.1263 +            <var title="">service</var> . <code title="dom-networkservice-name"><a href=
  1.1264 +            "#dom-networkservice-name">name</a></code>
  1.1265 +          </dt>
  1.1266 +          <dd>
  1.1267 +            <p>
  1.1268 +              The name of the user-selected service.
  1.1269 +            </p>
  1.1270 +          </dd>
  1.1271 +          <dt>
  1.1272 +            <var title="">service</var> . <code title="dom-networkservice-type"><a href=
  1.1273 +            "#dom-networkservice-type">type</a></code>
  1.1274 +          </dt>
  1.1275 +          <dd>
  1.1276 +            <p>
  1.1277 +              The <a>valid service type</a> token value of the user-selected service.
  1.1278 +            </p>
  1.1279 +          </dd>
  1.1280 +          <dt>
  1.1281 +            <var title="">service</var> . <code title="dom-networkservice-url"><a href=
  1.1282 +            "#dom-networkservice-url">url</a></code>
  1.1283 +          </dt>
  1.1284 +          <dd>
  1.1285 +            <p>
  1.1286 +              The control URL endpoint (including any required port information) of the user-selected control service
  1.1287 +              that has been added to the <a>entry script origin's URL whitelist</a>.
  1.1288 +            </p>
  1.1289 +          </dd>
  1.1290 +          <dt>
  1.1291 +            <var title="">service</var> . <code title="dom-networkservice-config"><a href=
  1.1292 +            "#dom-networkservice-config">config</a></code>
  1.1293 +          </dt>
  1.1294 +          <dd>
  1.1295 +            <p>
  1.1296 +              The configuration information associated with the service depending on the requested service type.
  1.1297 +            </p>
  1.1298 +          </dd>
  1.1299 +        </dl>
  1.1300 +        <p>
  1.1301 +          The <dfn id="dom-networkservice-id"><code>id</code></dfn> attribute is a unique identifier for the service.
  1.1302 +          The same service provided at different times or on different objects <em class="ct">MUST</em> have the same
  1.1303 +          <a href="#dom-networkservice-id"><code>id</code></a> value.
  1.1304 +        </p>
  1.1305 +        <p>
  1.1306 +          The <dfn id="dom-networkservice-name"><code>name</code></dfn> attribute represents a human-readable title for
  1.1307 +          the service.
  1.1308 +        </p>
  1.1309 +        <p>
  1.1310 +          The <dfn id="dom-networkservice-type"><code>type</code></dfn> attribute reflects the value of the <a>valid
  1.1311 +          service type</a> of the service.
  1.1312 +        </p>
  1.1313 +        <p>
  1.1314 +          The <dfn id="dom-networkservice-url"><code>url</code></dfn> attribute is an <a href=
  1.1315 +          "http://www.w3.org/TR/html5/urls.html#absolute-url"
  1.1316 +             class="externalDFN">absolute URL</a> pointing to the root HTTP endpoint for the service that has been
  1.1317 +             added to the <a>entry script origin's URL whitelist</a>. Web pages can subsequently use this value for
  1.1318 +             implicit cross-document messaging via various existing mechanisms (e.g. Web Sockets, Server-Sent Events,
  1.1319 +             Web Messaging, XMLHttpRequest).
  1.1320 +        </p>
  1.1321 +        <p>
  1.1322 +          The <dfn id="dom-networkservice-config"><code>config</code></dfn> attribute provides the raw configuration
  1.1323 +          information extracted from the given network service.
  1.1324 +        </p>
  1.1325 +      </section>
  1.1326 +      <section>
  1.1327 +        <h3>
  1.1328 +          States
  1.1329 +        </h3>
  1.1330 +        <dl class="domintro">
  1.1331 +          <dt>
  1.1332 +            <var title="">service</var> . <code title="dom-networkservice-online"><a href=
  1.1333 +            "#dom-networkservice-online">online</a></code>
  1.1334 +          </dt>
  1.1335 +          <dd>
  1.1336 +            <p>
  1.1337 +              Returns <code>true</code> if the service is reporting that it is accessible on the local network or
  1.1338 +              <code>false</code> if the service is reporting that it is no longer accessible (temporarily or
  1.1339 +              permanently) on the local network.
  1.1340 +            </p>
  1.1341 +          </dd>
  1.1342 +        </dl>
  1.1343 +        <p>
  1.1344 +          The <dfn id="dom-networkservice-online"><code>online</code></dfn> attribute indicates whether the service is
  1.1345 +          reporting itself as being either <var>online</var>, and therefore accessible on the local network, in which
  1.1346 +          case this attribute will return <code>true</code> or, <var>offline</var>, and therefore not accessible on the
  1.1347 +          local network, either temporarily or permanently, in which case this attribute will return
  1.1348 +          <code>false</code>. This attribute <em class="ct">MUST</em> default to <code>true</code>.
  1.1349 +        </p>
  1.1350 +      </section>
  1.1351 +      <section>
  1.1352 +        <h3>
  1.1353 +          Events
  1.1354 +        </h3>
  1.1355 +        <p>
  1.1356 +          The following are the event handlers (and their corresponding event handler event types) that <em class=
  1.1357 +          "ct">MUST</em> be supported, as IDL attributes, by all objects implementing the <a href=
  1.1358 +          "#networkservice"><code>NetworkService</code></a> interface:
  1.1359 +        </p>
  1.1360 +        <table border="1"
  1.1361 +               summary="Event handlers for NetworkService objects">
  1.1362 +          <thead>
  1.1363 +            <tr>
  1.1364 +              <th>
  1.1365 +                <span title="event handlers">Event handler</span>
  1.1366 +              </th>
  1.1367 +              <th>
  1.1368 +                <span>Event handler event type</span>
  1.1369 +              </th>
  1.1370 +            </tr>
  1.1371 +          </thead>
  1.1372 +          <tbody>
  1.1373 +            <tr>
  1.1374 +              <td>
  1.1375 +                <dfn id="dom-networkservice-onnotify"
  1.1376 +                    title="dom-NetworkService-onnotify"><code>onnotify</code></dfn>
  1.1377 +              </td>
  1.1378 +              <td>
  1.1379 +                <a href="#event-notify"><code>notify</code></a>
  1.1380 +              </td>
  1.1381 +            </tr>
  1.1382 +            <tr>
  1.1383 +              <td>
  1.1384 +                <dfn id="dom-networkservice-onserviceonline"
  1.1385 +                    title="dom-NetworkService-onserviceonline"><code>onserviceonline</code></dfn>
  1.1386 +              </td>
  1.1387 +              <td>
  1.1388 +                <a href="#event-serviceonline"><code>serviceonline</code></a>
  1.1389 +              </td>
  1.1390 +            </tr>
  1.1391 +            <tr>
  1.1392 +              <td>
  1.1393 +                <dfn id="dom-networkservice-onserviceoffline"
  1.1394 +                    title="dom-NetworkService-onserviceoffline"><code>onserviceoffline</code></dfn>
  1.1395 +              </td>
  1.1396 +              <td>
  1.1397 +                <a href="#event-serviceoffline"><code>serviceoffline</code></a>
  1.1398 +              </td>
  1.1399 +            </tr>
  1.1400 +          </tbody>
  1.1401 +        </table>
  1.1402 +      </section>
  1.1403 +    </section>
  1.1404 +    <section>
  1.1405 +      <h2>
  1.1406 +        Service Discovery
  1.1407 +      </h2>
  1.1408 +      <p>
  1.1409 +        A <a>user agent</a> conforming to this specification <em class="ct">MAY</em> implement <acronym title=
  1.1410 +        "Simple Service Discovery Protocol">SSDP</acronym> [[!UPNP-DEVICEARCH11]] and Zeroconf [[!DNS-SD]] + [[!MDNS]]
  1.1411 +        service discovery mechanisms to enable Web pages to request and connect with HTTP services running on networked
  1.1412 +        devices, discovered via either mechanism, through this API. When a <a>user agent</a> implements either of these
  1.1413 +        service discovery mechanisms, then it <em class="ct">MUST</em> conform to the corresponding algorithms provided
  1.1414 +        in this section of the specification.
  1.1415 +      </p>
  1.1416 +      <p>
  1.1417 +        This section presents how the results of these two service discovery mechanisms will be matched to requested
  1.1418 +        service types, how the user agent stores available and active services, how their properties are applied to any
  1.1419 +        resulting <a href="#networkservice"><code>NetworkService</code></a> objects.
  1.1420 +      </p>
  1.1421 +      <p>
  1.1422 +        It is expected that user agents will perform these service discovery mechansisms asynchronously and
  1.1423 +        periodically update the <a>list of networked devices</a> as required. The timing of any service discovery
  1.1424 +        mechanisms is an implementation detail left to the discretion of the implementer (e.g. once on user agent
  1.1425 +        start-up, every X seconds during user agent execution or on invocation of this API from a Web page).
  1.1426 +      </p>
  1.1427 +      <p>
  1.1428 +        The <dfn>list of available service records</dfn> is a single dynamic internal lookup table within user agents
  1.1429 +        that is used to track all the services that have been discovered and are available in the current network at
  1.1430 +        any given time. At any point during the running of either of the two service discovery mechanisms then existing
  1.1431 +        entries within this table can be updated, entries can be added and entries can be removed as the status of
  1.1432 +        networked services changes according to the rules defined in this specification.
  1.1433 +      </p>
  1.1434 +      <p>
  1.1435 +        The <dfn>list of authorized service records</dfn> is a single dynamic internal lookup table within user agents
  1.1436 +        that is used to track the current services that are being shared with web pages at any given time from the
  1.1437 +        <a>list of available service records</a>. Each record in the <a>list of authorized service records</a> is
  1.1438 +        associated with a <var>services manager</var> object that is assigned as part of the <a href=
  1.1439 +        "#dom-navigator-getnetworkservices"><code>getNetworkServices()</code></a> algorithm.
  1.1440 +      </p>
  1.1441 +      <p>
  1.1442 +        The rule for <dfn>adding an available service</dfn> is the process of adding a new service or updating an
  1.1443 +        existing service in the <a>list of available service records</a> that is generally available on the user's
  1.1444 +        current network. This rule takes one argument, <var>network service record</var>, and consists of running the
  1.1445 +        following steps:
  1.1446 +      </p>
  1.1447 +      <ol class="rule">
  1.1448 +        <li>Let <var>new service registration flag</var> be <code>true</code>.
  1.1449 +        </li>
  1.1450 +        <li>For each <var>existing service record</var> in the current <a>list of available service records</a>, run
  1.1451 +        the following sub-steps:
  1.1452 +          <ol class="rule">
  1.1453 +            <li>If the <var>existing service record</var>'s <code>id</code> property does not equal <var>network
  1.1454 +            service record</var>'s <code>id</code> property then abort any remaining sub-steps and continue at the next
  1.1455 +            available <var>existing service record</var>.
  1.1456 +            </li>
  1.1457 +            <li>Set <var>new service registration flag</var> to <code>false</code>.
  1.1458 +            </li>
  1.1459 +            <li>Replace the value of <var>existing service record</var> in the current <a>list of available service
  1.1460 +            records</a> with the value of <var>network service record</var>.
  1.1461 +            </li>
  1.1462 +          </ol>
  1.1463 +        </li>
  1.1464 +        <li>If <var>new service registration flag</var> is set to <code>true</code> then add <var>network service
  1.1465 +        record</var> to the <a>list of available service records</a> as a new entry.
  1.1466 +        </li>
  1.1467 +        <li>For each <var>active service</var> in the <a>list of authorized service records</a> run the following
  1.1468 +        steps:
  1.1469 +          <ol class="rule">
  1.1470 +            <li>If <var>network service record</var>'s <code>type</code> property does not equal the current
  1.1471 +            <var>active service</var>'s <code>type</code> attribute then abort any remaining sub-steps for this
  1.1472 +            <var>active service</var> and continue at the next available <var>active service</var>.
  1.1473 +            </li>
  1.1474 +            <li>If the <var>new service registration flag</var> is set to <code>true</code> then increment the
  1.1475 +              <a href="#dom-networkservices-servicesavailable"><code>servicesAvailable</code></a> attribute of the
  1.1476 +              <var>services manager</var> associated with the current <var>active service</var> object by
  1.1477 +              <code>1</code> and then <a href=
  1.1478 +              "http://www.whatwg.org/specs/web-apps/current-work/complete/webappapis.html#queue-a-task"
  1.1479 +                  class="externalDFN">queue a task</a> to dispatch a newly created event with the name <a href=
  1.1480 +                  "#event-serviceavailable"><code>serviceavailable</code></a> that uses the <a href=
  1.1481 +                  "http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#event"
  1.1482 +                  class="externalDFN"><code>Event</code></a> interface, which does not bubble, is not cancellable, and
  1.1483 +                  has no default action, at the <var>services manager</var> associated with the current <var>active
  1.1484 +                  service</var> object.
  1.1485 +            </li>
  1.1486 +            <li>Set <var>active service</var>'s <a href="#dom-networkservice-online"><code>online</code></a> attribute
  1.1487 +            to <code>true</code> and then <a href=
  1.1488 +            "http://www.whatwg.org/specs/web-apps/current-work/complete/webappapis.html#queue-a-task"
  1.1489 +                  class="externalDFN">queue a task</a> to dispatch a newly created event with the name <a href=
  1.1490 +                  "#event-serviceonline"><code>serviceonline</code></a> that uses the <a href=
  1.1491 +                  "http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#event"
  1.1492 +                  class="externalDFN"><code>Event</code></a> interface, which does not bubble, is not cancellable, and
  1.1493 +                  has no default action, at the current <var>active service</var> object.
  1.1494 +            </li>
  1.1495 +          </ol>
  1.1496 +        </li>
  1.1497 +      </ol>
  1.1498 +      <p>
  1.1499 +        The rule for <dfn>removing an available service</dfn> is the general process of removing a service from the
  1.1500 +        <a>list of available service records</a> that has left the user's current network or has otherwise expired.
  1.1501 +        This rule takes one argument, <var>service identifier</var>, and consists of running the following steps:
  1.1502 +      </p>
  1.1503 +      <ol class="rule">
  1.1504 +        <li>For each <var>existing service record</var> in the current <a>list of available service records</a>, run
  1.1505 +        the following sub-steps:
  1.1506 +          <ol class="rule">
  1.1507 +            <li>If the <var>existing service record</var>'s <code>id</code> property does not match <var>service
  1.1508 +            identifier</var> then skip any remaining sub-steps for the current <var>existing service record</var> and
  1.1509 +            continue at the next available <var>existing service record</var>.
  1.1510 +            </li>
  1.1511 +            <li>If the <var>existing service record</var>'s <code>type</code> property begins with the DOMString
  1.1512 +            "<code>upnp:</code>" and <var>existing service record</var>'s <code>eventsURL</code> property is set then
  1.1513 +            run the rule to <a>terminate an existing UPnP Events Subscription</a>, if one is currently active (as a
  1.1514 +            result of having previously called <a>setup a UPnP Events Subscription</a> against the current
  1.1515 +            <var>existing service record</var>).
  1.1516 +            </li>
  1.1517 +            <li>For each <var>active service</var> in <a>list of authorized service records</a> run the following
  1.1518 +            steps:
  1.1519 +              <ol class="rule">
  1.1520 +                <li>If <var>existing service record</var>'s <code>type</code> property does not equal the current <var>
  1.1521 +                  active service</var>'s <code>type</code> attribute then abort any remaining sub-steps for this
  1.1522 +                  <var>active service</var> and continue at the next available <var>active service</var>.
  1.1523 +                </li>
  1.1524 +                <li>Decrement the <a href="#dom-networkservices-servicesavailable"><code>servicesAvailable</code></a>
  1.1525 +                attribute of the <var>services manager</var> associated with the current <var>active service</var>
  1.1526 +                object by <code>1</code> and then <a href=
  1.1527 +                "http://www.whatwg.org/specs/web-apps/current-work/complete/webappapis.html#queue-a-task"
  1.1528 +                      class="externalDFN">queue a task</a> to dispatch a newly created event with the name <a href=
  1.1529 +                      "#event-serviceunavailable"><code>serviceunavailable</code></a> that uses the <a href=
  1.1530 +                      "http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#event"
  1.1531 +                      class="externalDFN"><code>Event</code></a> interface, which does not bubble, is not cancellable,
  1.1532 +                      and has no default action, at the <var>services manager</var> associated with the current
  1.1533 +                      <var>active service</var> object.
  1.1534 +                </li>
  1.1535 +                <li>Set <var>active service</var>'s <a href="#dom-networkservice-online"><code>online</code></a>
  1.1536 +                attribute to <code>false</code> and then <a href=
  1.1537 +                "http://www.whatwg.org/specs/web-apps/current-work/complete/webappapis.html#queue-a-task"
  1.1538 +                      class="externalDFN">queue a task</a> to dispatch a newly created event with the name <a href=
  1.1539 +                      "#event-serviceoffline"><code>serviceoffline</code></a> that uses the <a href=
  1.1540 +                      "http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#event"
  1.1541 +                      class="externalDFN"><code>Event</code></a> interface, which does not bubble, is not cancellable,
  1.1542 +                      and has no default action, at the current <var>active service</var> object.
  1.1543 +                </li>
  1.1544 +              </ol>
  1.1545 +            </li>
  1.1546 +            <li>Remove <var>existing service record</var> from the current <a>list of available service records</a>.
  1.1547 +            </li>
  1.1548 +          </ol>
  1.1549 +        </li>
  1.1550 +      </ol>
  1.1551 +      <p>
  1.1552 +        User agents <em class="ct">SHOULD</em> expire a service record from the <a>list of available service
  1.1553 +        records</a> when its <code>expiryTimestamp</code> attribute exceeds the current UTC timestamp. When this
  1.1554 +        condition is met the <a>user agent</a> SHOULD run the rule for <a>removing an available service</a>, passing in
  1.1555 +        the expired service record's <code>id</code> attribute as the only argument.
  1.1556 +      </p>
  1.1557 +      <section>
  1.1558 +        <h4>
  1.1559 +          Zeroconf (<abbr title="Multicast DNS">mDNS</abbr> + <abbr title="Domain Name System">DNS</abbr>-<abbr title=
  1.1560 +          "Service Discovery">SD</abbr>)
  1.1561 +        </h4>
  1.1562 +        <p>
  1.1563 +          For each DNS response received from a user-agent-initiated Multicast DNS Browse for <abbr title=
  1.1564 +          "DNS Pointer Record">PTR</abbr> records with the name <code>_services._dns-sd._udp</code> on the resolved
  1.1565 +          recommended automatic browsing domain [[!MDNS]], the <a>user agent</a> <em class="ct">MUST</em> run the
  1.1566 +          following steps:
  1.1567 +        </p>
  1.1568 +        <ol class="rule">
  1.1569 +          <li>Let <var>service mDNS responses</var> be an array of PTR records received by issuing a Multicast DNS
  1.1570 +          Browse for PTR records with the name of the current discovered service type.
  1.1571 +          </li>
  1.1572 +          <li>For each Object <var>service mDNS response</var> in <var>service mDNS responses</var>, run the following
  1.1573 +          steps:
  1.1574 +            <ol>
  1.1575 +              <li>Let <var>network service record</var> be an Object consisting of the following empty properties:
  1.1576 +              <code>id</code>, <code>name</code>, <code>type</code>, <code>url</code>, <code>config</code>,
  1.1577 +              <code>expiryTimestamp</code>.
  1.1578 +              </li>
  1.1579 +              <li>Set <var>network service record</var>'s <code>id</code> property to the value of the full PTR Service
  1.1580 +              Instance Name [[!MDNS]].
  1.1581 +              </li>
  1.1582 +              <li>Set <var>network service record</var>'s <code>name</code> property to the value of the PTR Service
  1.1583 +              Instance Name's <var>Instance</var> component [[!MDNS]].
  1.1584 +              </li>
  1.1585 +              <li>Set <var>network service record</var>'s <code>type</code> property to the concatenation of the string
  1.1586 +              <code>zeroconf:</code> followed be the value of the PTR Service Instance Name's <var>Service</var>
  1.1587 +              component [[!MDNS]].
  1.1588 +              </li>
  1.1589 +              <li>Set <var>network service record</var>'s <code>url</code> property to the resolvable Service URL
  1.1590 +              obtained from performing an DNS-SD Lookup [[!DNS-SD]] of the current service from the PTR record provided
  1.1591 +              [[!MDNS]].
  1.1592 +              </li>
  1.1593 +              <li>Set <var>network service record</var>'s <code>config</code> property to the string value of the
  1.1594 +              contents of the first DNS-SD TXT record associated with the <var>service mDNS response</var> as defined
  1.1595 +              in [[!DNS-SD]].
  1.1596 +              </li>
  1.1597 +              <li>Set <var>network service record</var>'s <code>expiryTimestamp</code> property to the value of the
  1.1598 +              current date, in UTC timestamp format, plus a value of <code>120</code> seconds.
  1.1599 +              </li>
  1.1600 +              <li>Run the general rule for <a>adding an available service</a>, passing in the current <var>network
  1.1601 +              service record</var> as the only argument.
  1.1602 +              </li>
  1.1603 +            </ol>
  1.1604 +          </li>
  1.1605 +        </ol>
  1.1606 +      </section>
  1.1607 +      <section>
  1.1608 +        <h5>
  1.1609 +          Simple Service Discovery Protocol (<abbr title="Simple Service Discovery Protocol">SSDP</abbr>)
  1.1610 +        </h5>
  1.1611 +        <p>
  1.1612 +          A user agent that implements UPnP service discovery <em class="ct">MUST</em> issue an <dfn>advertisement for
  1.1613 +          UPnP root devices</dfn> against the user's current local network according to the full normative text and
  1.1614 +          timing provided in 'Section 1.3.2: Search request with M-SEARCH' detailed in [[!UPNP-DEVICEARCH11]].
  1.1615 +        </p>
  1.1616 +        <p>
  1.1617 +          The user agent <em class="ct">MUST</em> issue all <a title=
  1.1618 +          "advertisement for UPnP root devices">advertisements for UPnP root devices</a> with a HTTP request line equal
  1.1619 +          to <code>M-SEARCH * HTTP/1.1</code>, with a HOST header equal to the reserved multicast address and port of
  1.1620 +          <code>239.255.255.250:1900</code>, a MAN header equal to <code>ssdp:discover</code>, an ST header equal to
  1.1621 +          <code>upnp:rootdevice</code> and a user-agent defined MX header equal to a <dfn>maximum UPnP advertisement
  1.1622 +          response wait time</dfn> value between <code>1</code> and <code>5</code> seconds.
  1.1623 +        </p>
  1.1624 +        <p>
  1.1625 +          The user agent <em class="ct">MUST</em> listen for incoming requests and process any incoming responses to
  1.1626 +          any <a>advertisement for UPnP root devices</a> on the <dfn>standard UPnP address and port</dfn>, on all
  1.1627 +          current local network interface addresses with the port <code>1900</code>, according to the rules defined in
  1.1628 +          this section.
  1.1629 +        </p>
  1.1630 +        <p>
  1.1631 +          For each <dfn>HTTP Response</dfn> following an initial <a>advertisement for UPnP root devices</a> sent on a
  1.1632 +          <a>standard UPnP address and port</a> the user agent <em class="ct">MUST</em> run the following steps:
  1.1633 +        </p>
  1.1634 +        <ol class="rule">
  1.1635 +          <li>If the <a>HTTP Response</a> is not a HTTP 200 OK response then this response is invalid and the user
  1.1636 +          agent <em class="ct">MUST</em> discard this response, abort any remaining steps and return. The user agent
  1.1637 +          <em class="ct">MAY</em> issue a new <a>advertisement for UPnP root devices</a> as a result of this error
  1.1638 +          occurring.
  1.1639 +          </li>
  1.1640 +          <li>If the <a>maximum UPnP advertisement response wait time</a> has been exceeded since the initial
  1.1641 +          <a>advertisement for UPnP root devices</a> was sent then the <a>HTTP Response</a> is invalid and the user
  1.1642 +          agent <em class="ct">MUST</em> discard this response, abort any remaining steps and return.
  1.1643 +          </li>
  1.1644 +          <li>Let <var>ssdp device</var> be an Object with a property for each HTTP header received in the <a>HTTP
  1.1645 +          Response</a>, with each key being the name of a HTTP response header and each value being that HTTP response
  1.1646 +          header's value.
  1.1647 +          </li>
  1.1648 +          <li>If <var>ssdp device</var> does not contain at least one <var>CACHE-CONTROL</var> entry, at least one
  1.1649 +          <var>USN</var> entry, at least one <var>ST</var> entry and at least one <var>LOCATION</var> entry or the
  1.1650 +          value of its <var>ST</var> entry is not <code>upnp:rootdevice</code>, then the <a>HTTP Response</a> is
  1.1651 +          invalid and the <a>user agent</a> <em class="ct">MUST</em> discard this response, abort any remaining steps
  1.1652 +          and return.
  1.1653 +          </li>
  1.1654 +          <li>The user agent <em class="ct">MUST</em> run the rule for <a>obtaining a UPnP Device Description File</a>
  1.1655 +          passing in the first occurrence of <var>LOCATION</var> from <var>ssdp device</var> as the <var>device
  1.1656 +          descriptor URL</var> argument and the first occurrence of <var>USN</var> from <var>ssdp device</var> as the
  1.1657 +          <var>device identifier</var> argument and the first occurrence of <var>CACHE-CONTROL</var> from <var>ssdp
  1.1658 +          device</var> as the <var>device expiry</var> argument.
  1.1659 +          </li>
  1.1660 +        </ol>
  1.1661 +        <p>
  1.1662 +          For each <dfn>HTTP Request</dfn> received on a <a>standard UPnP address and port</a> the user agent
  1.1663 +          <em class="ct">MUST</em> run the following steps:
  1.1664 +        </p>
  1.1665 +        <ol class="rule">
  1.1666 +          <li>If the <a>HTTP Request</a> is not a HTTP NOTIFY request then it is not a valid UPnP Request and the user
  1.1667 +          agent <em class="ct">MUST</em> return a HTTP 200 OK response, discard this request, abort any remaining steps
  1.1668 +          and return.
  1.1669 +          </li>
  1.1670 +          <li>Let <var>ssdp device</var> be an Object with a property for each HTTP header received in the <a>HTTP
  1.1671 +          Request</a>, with each key being the name of a HTTP header and each value being that HTTP header's value.
  1.1672 +          </li>
  1.1673 +          <li>If <var>ssdp device</var> does not contain at least one <var>CACHE-CONTROL</var> entry, at least one
  1.1674 +          <var>USN</var> entry, at least one <var>NT</var> entry, at least one <var>NTS</var> entry and at least one
  1.1675 +          <var>LOCATION</var> entry or the value of its <var>NT</var> entry is not <code>upnp:rootdevice</code>, then
  1.1676 +          the <a>HTTP Request</a> is a malformed UPnP Request and the <a>user agent</a> <em class="ct">MUST</em> return
  1.1677 +          a 400 Bad Request response, discard this request, abort any remaining steps and return.
  1.1678 +          </li>
  1.1679 +          <li>If <var>ssdp device</var>'s <var>NTS</var> entry is equal to <code>ssdp:alive</code> or
  1.1680 +          <code>ssdp:update</code> then the user agent <em class="ct">MUST</em> run the rule for <a>obtaining a UPnP
  1.1681 +          Device Description File</a> passing in the first occurrence of <var>LOCATION</var> from <var>ssdp
  1.1682 +          device</var> as the <var>device descriptor URL</var> argument and the first occurrence of <var>USN</var> from
  1.1683 +          <var>ssdp device</var> as the <var>device identifier</var> argument and the first occurrence of
  1.1684 +          <var>CACHE-CONTROL</var> from <var>ssdp device</var> as the <var>device expiry</var>.<br>
  1.1685 +            <br>
  1.1686 +            Otherwise, if <var>ssdp device</var>'s <var>NTS</var> entry is equal to <code>ssdp:byebye</code> then the
  1.1687 +            user agent <em class="ct">MUST</em> run the rule for <a>removing all services from a registered UPnP
  1.1688 +            Device</a> passing in the first occurrence of <var>USN</var> from <var>ssdp device</var> as the <var>device
  1.1689 +            identifier</var> argument.
  1.1690 +          </li>
  1.1691 +        </ol>
  1.1692 +        <p>
  1.1693 +          The rule for <dfn>obtaining a UPnP Device Description File</dfn> is the process of obtaining the contents of
  1.1694 +          a standard UPnP Device Description [[!UPNP-DEVICEARCH11]] from a URL-based resource. This rule takes three
  1.1695 +          arguments - <var>device descriptor URL</var>, <var>device identifier</var> and <var>device expiry</var> - and
  1.1696 +          when called the user agent <em class="ct">MUST</em> run the following steps:
  1.1697 +        </p>
  1.1698 +        <ol class="rule">
  1.1699 +          <li>Let <var>device descriptor file</var> contain the contents of the file located at the URL provided in
  1.1700 +          <var>device descriptor URL</var> obtained according to the rules defined in 'Section 2.11: Retrieving a
  1.1701 +          description using HTTP' in [[!UPNP-DEVICEARCH11]].
  1.1702 +          </li>
  1.1703 +          <li>If the value provided in <var>device descriptor URL</var> cannot be resolved as a reachable URL on the
  1.1704 +          current network or the <var>root device descriptor file</var> remains empty then it is invalid and the
  1.1705 +          <a>user agent</a> <em class="ct">MUST</em> abort any remaining steps and return.
  1.1706 +          </li>
  1.1707 +          <li>Run the rule for <a>processing a UPnP Device Description File</a>, passing in the current <var>device
  1.1708 +          descriptor file</var>, <var>device identifier</var> and <var>device expiry</var> arguments.
  1.1709 +          </li>
  1.1710 +          <li>If the current <var>device descriptor file</var> contains a <code>&lt;deviceList&gt;</code> element then
  1.1711 +          for each <code>&lt;device&gt;</code> element within <code>&lt;deviceList&gt;</code> - herein known as an
  1.1712 +          <var>embedded device descriptor file</var> - the user agent <em class="ct">MUST</em> run the rule for
  1.1713 +          <a>processing a UPnP Device Description File</a>, passing in the current <var>embedded device descriptor
  1.1714 +          file</var> as the <var>device descriptor file</var> argument, along with the common <var>device
  1.1715 +          identifier</var> and <var>device expiry</var> arguments.
  1.1716 +          </li>
  1.1717 +        </ol>
  1.1718 +        <p>
  1.1719 +          The rule for <dfn>processing a UPnP Device Description File</dfn> is the process of parsing the contents of a
  1.1720 +          standard UPnP Device Description [[!UPNP-DEVICEARCH11]] and registering the UPnP services contained therein
  1.1721 +          within the <a>list of available service records</a>.
  1.1722 +        </p>
  1.1723 +        <p>
  1.1724 +          The rule for <a>processing a UPnP Device Description File</a> takes three arguments - <var>device descriptor
  1.1725 +          file</var>, <var>device identifier</var> and <var>device expiry</var> - and when called the user agent
  1.1726 +          <em class="ct">MUST</em> run the following steps:
  1.1727 +        </p>
  1.1728 +        <ol class="rule">
  1.1729 +          <li>Let <var>advertised services</var> be a list of all advertised services obtained from the <var>device
  1.1730 +          descriptor file</var> containing the value of the first occurrence of the <code>&lt;serviceList&gt;</code>
  1.1731 +          element as it is defined in 'Section 2.3: Device Description' in [[!UPNP-DEVICEARCH11]].
  1.1732 +          </li>
  1.1733 +          <li>For each <code>&lt;service&gt;</code> element - known as an <var>advertised service</var> - in
  1.1734 +          <var>advertised services</var> run the following steps:
  1.1735 +            <ol class="rule">
  1.1736 +              <li>Let <var>network service record</var> be a new Object consisting of the following empty properties:
  1.1737 +              <code>id</code>, <code>deviceId</code>, <code>name</code>, <code>type</code>, <code>url</code>,
  1.1738 +              <code>eventsUrl</code>, <code>config</code>, <code>expiryTimestamp</code>.
  1.1739 +              </li>
  1.1740 +              <li>Set <var>network service record</var>'s <code>id</code> property to the concatenated string value of
  1.1741 +              <var>device identifier</var> with the <var>advertised service</var>'s <code>&lt;serviceId&gt;</code>
  1.1742 +              sub-element.
  1.1743 +              </li>
  1.1744 +              <li>Set <var>network service record</var>'s <code>deviceId</code> property to the value of <var>device
  1.1745 +              identifier</var>.
  1.1746 +              </li>
  1.1747 +              <li>Set <var>network service record</var>'s <code>name</code> property to the string value of the first
  1.1748 +              occurrence of the <var>advertised service</var>'s <code>&lt;serviceId&gt;</code> sub-element.
  1.1749 +              </li>
  1.1750 +              <li>Set <var>network service record</var>'s <code>type</code> property to the concatenation of the string
  1.1751 +              <code>upnp:</code> followed by the string value of the first occurrence of the <var>advertised
  1.1752 +              service</var>'s <code>&lt;serviceType&gt;</code> sub-element.
  1.1753 +              </li>
  1.1754 +              <li>Set <var>network service record</var>'s <code>url</code> property to the string value of the first
  1.1755 +              occurrence of the <var>advertised service</var>'s <code>&lt;controlURL&gt;</code> sub-element.
  1.1756 +              </li>
  1.1757 +              <li>Set <var>network service record</var>'s <code>config</code> property to the string value of the
  1.1758 +              contents of the first occurrence of the <code>&lt;device&gt;</code> element in the <var>device descriptor
  1.1759 +              file</var>.
  1.1760 +              </li>
  1.1761 +              <li>If <var>advertised service</var>'s <code>&lt;eventSubURL&gt;</code> sub-element is not empty, then
  1.1762 +              set <var>network service record</var>'s <code>eventsUrl</code> property to the string value of the first
  1.1763 +              occurrence of the <var>advertised service</var>'s <code>&lt;eventSubURL&gt;</code> sub-element.
  1.1764 +              Otherwise, do not set <var>network service record</var>'s <code>eventsUrl</code> property.
  1.1765 +              </li>
  1.1766 +              <li>Set <var>network service record</var>'s <code>expiryTimestamp</code> property to the value of the
  1.1767 +              current date, in UTC timestamp format, plus the value of <var>device expiry</var>.
  1.1768 +              </li>
  1.1769 +              <li>Run the general rule for <a>adding an available service</a>, passing in the current <var>network
  1.1770 +              service record</var> as the only argument.
  1.1771 +              </li>
  1.1772 +            </ol>
  1.1773 +          </li>
  1.1774 +        </ol>
  1.1775 +        <p>
  1.1776 +          The rule for <dfn>removing all services from a registered UPnP Device</dfn> is the process of removing all
  1.1777 +          services associated with a device from the <a>list of available service records</a> that has left the user's
  1.1778 +          current network or has otherwise timed out or expired. This rule takes one argument, <var>device
  1.1779 +          identifier</var>, and consists of running the following steps:
  1.1780 +        </p>
  1.1781 +        <ol class="rule">
  1.1782 +          <li>For each <var>existing service record</var> in the current <a>list of available service records</a>, run
  1.1783 +          the following sub-steps:
  1.1784 +            <ol class="rule">
  1.1785 +              <li>If the <var>existing service record</var>'s <code>deviceId</code> property does not match <var>device
  1.1786 +              identifier</var> then skip any remaining sub-steps for the current <var>existing service record</var> and
  1.1787 +              continue at the next available <var>existing service record</var>.
  1.1788 +              </li>
  1.1789 +              <li>Run the general rule for <a>removing an available service</a> passing in <var>existing service
  1.1790 +              record</var>'s <code>id</code> property as the only argument.
  1.1791 +              </li>
  1.1792 +            </ol>
  1.1793 +          </li>
  1.1794 +        </ol>
  1.1795 +        <p>
  1.1796 +          When the <a>user agent</a> is to <dfn>setup a UPnP Events Subscription</dfn>, it is to run the following
  1.1797 +          steps with the current <var>network service record</var> object as defined in 'Section 4.1.2: SUBSCRIBE with
  1.1798 +          NT and CALLBACK' in [[!UPNP-DEVICEARCH11]]:
  1.1799 +        </p>
  1.1800 +        <ol class="rule">
  1.1801 +          <li>If <var>network service record</var>'s <code>eventsUrl</code> property is empty then the <a>user
  1.1802 +          agent</a> <em class="ct">MUST</em> abort these steps.
  1.1803 +          </li>
  1.1804 +          <li>Let <var>callback URL</var> be the value of creating a new <a>user-agent generated callback url</a>.
  1.1805 +          </li>
  1.1806 +          <li>Send a HTTP SUBSCRIBE request with a <em>NT</em> header with a string value of <code>upnp:event</code>, a
  1.1807 +          <em>TIMEOUT</em> header with a user-agent defined timeout value (in the form <code>Second-XX</code> where
  1.1808 +          <code>XX</code> is the user-agent defined timeout value in seconds) and a <em>CALLBACK</em> header with a
  1.1809 +          string value of <var>callback URL</var> towards the <var>network service record</var>'s
  1.1810 +          <code>eventsUrl</code> property.
  1.1811 +          </li>
  1.1812 +          <li>If a non-200 OK response is received from the HTTP SUBSCRIBE request then the <a>user agent</a>
  1.1813 +            <em class="ct">MUST</em> abort these steps.
  1.1814 +          </li>
  1.1815 +          <li>On receiving a valid 200 OK response, run the following steps:
  1.1816 +            <ol class="rule">
  1.1817 +              <li>Let <var>callback ID</var> equal the string value of the first included <em>SID</em> header, if it
  1.1818 +              exists.
  1.1819 +              </li>
  1.1820 +              <li>Let <var>timeout date</var> equal the sum of the current UTC date value plus the integer value of the
  1.1821 +              first included <em>TIMEOUT</em> header (minus the leading string of <code>Second-</code>), if it exists.
  1.1822 +              </li>
  1.1823 +              <li>Run the following steps aynchronously and continue to the step labeled <em>listen</em> below.
  1.1824 +              </li>
  1.1825 +              <li>
  1.1826 +                <em>Refresh Subscription</em>: Run the following steps at a set interval (X) within the <a>user
  1.1827 +                agent</a>:
  1.1828 +                <ol class="rule">
  1.1829 +                  <li>Let <var>current date</var> equal the current UTC date.
  1.1830 +                  </li>
  1.1831 +                  <li>If <var>current date</var> is less than the <var>timeout date</var> then continue to the step
  1.1832 +                  labeled <em>refresh subscription</em> above.
  1.1833 +                  </li>
  1.1834 +                  <li>Send a HTTP SUBSCRIBE request with a <em>SID</em> header with the string value of <var>callback
  1.1835 +                  ID</var> and a user-agent defined <em>TIMEOUT</em> header (in the form <code>Second-XX</code> where
  1.1836 +                  <code>XX</code> is the user-agent defined timeout value in seconds) towards the <var>network service
  1.1837 +                  record</var>'s <code>eventsUrl</code> property.
  1.1838 +                  </li>
  1.1839 +                  <li>On receiving a valid 200 OK, update <var>callback ID</var> with the string value of the first
  1.1840 +                  included <em>SID</em> header, if it exists. All other HTTP responses should cause the <a>user
  1.1841 +                  agent</a> to continue from the step labeled <em>refresh subscription</em> above.
  1.1842 +                  </li>
  1.1843 +                </ol>
  1.1844 +              </li>
  1.1845 +              <li>
  1.1846 +                <em>Listen</em>: For each HTTP NOTIFY request received at the <var>callback URL</var> the <a>user
  1.1847 +                agent</a> is to run the following steps:
  1.1848 +                <ol class="rule">
  1.1849 +                  <li>Let <var>content clone</var> be the result of obtaining the message body of the HTTP NOTIFY
  1.1850 +                  request. If <var>content clone</var> is empty, then the <a>user agent</a> <em class="ct">MUST</em>
  1.1851 +                  abort these steps.
  1.1852 +                  </li>
  1.1853 +                  <li>Let <var>notification event</var> be a new simple event that uses the <a href=
  1.1854 +                  "http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#event"
  1.1855 +                        class="externalDFN"><code>Event</code></a> interface with the name <a href=
  1.1856 +                        "#event-notify"><code>notify</code></a>, which does not bubble, is not cancellable, and has no
  1.1857 +                        default action.
  1.1858 +                  </li>
  1.1859 +                  <li>Let the <code>data</code> attribute of <var>notification event</var> have the DOMString value of
  1.1860 +                  <var>content clone</var>.
  1.1861 +                  </li>
  1.1862 +                  <li>
  1.1863 +                    <a href="http://www.whatwg.org/specs/web-apps/current-work/complete/webappapis.html#queue-a-task"
  1.1864 +                        class="externalDFN">Queue a task</a> to dispatch <var>notification event</var> at the current
  1.1865 +                        <a><code>NetworkService</code></a> object.
  1.1866 +                  </li>
  1.1867 +                </ol>
  1.1868 +              </li>
  1.1869 +            </ol>
  1.1870 +          </li>
  1.1871 +        </ol>
  1.1872 +        <p>
  1.1873 +          A <a>user agent</a> can <dfn>terminate an existing UPnP Events Subscription</dfn> at any time for any
  1.1874 +          <var>active service</var> in the <a>list of authorized service records</a> by sending an HTTP UNSUBSCRIBE
  1.1875 +          request - as defined in 'Section 4.1.4: Canceling a subscription with UNSUBSCRIBE' in [[!UPNP-DEVICEARCH11]]
  1.1876 +          - with a HOST header set to that <var>active service</var>'s <code>eventsUrl</code> property and a SID header
  1.1877 +          set to the <var>callback ID</var> obtained when the initial <a>setup a UPnP Events Subscription</a> action
  1.1878 +          occurred.
  1.1879 +        </p>
  1.1880 +      </section>
  1.1881 +      <section>
  1.1882 +        <h3>
  1.1883 +          Network Topology Monitoring
  1.1884 +        </h3>
  1.1885 +        <div>
  1.1886            <p>
  1.1887 -            A unique identifier for the given user-selected service instance.
  1.1888 +            When the <a>user agent</a> detects that the user has dropped from their connected network then, for each
  1.1889 +            <var>existing service record</var> in the <a>list of available service records</a>, the user agent
  1.1890 +            <em class="ct">MUST</em> run the general rule for <a>removing an available service</a> passing in each
  1.1891 +            <var>existing service record</var>'s <code>id</code> property as the only argument for each call.
  1.1892            </p>
  1.1893 -        </dd>
  1.1894 -        <dt>
  1.1895 -          <var title="">service</var>
  1.1896 -           .
  1.1897 -          <code title="dom-networkservice-name">
  1.1898 -            <a href="#dom-networkservice-name">name</a>
  1.1899 -          </code>
  1.1900 -        </dt>
  1.1901 -        <dd>
  1.1902            <p>
  1.1903 -            The name of the user-selected service.
  1.1904 +            When the <a>user agent</a> detects that the user has connected to a new network or reconnected to an
  1.1905 +            existing network, then it <em class="ct">SHOULD</em> restart its discovery mechanisms as defined in the
  1.1906 +            <a href="#service-discovery">Service Discovery</a> section of this specification, maintaining the existing
  1.1907 +            <a>list of authorized service records</a> currently in use.
  1.1908            </p>
  1.1909 -        </dd>
  1.1910 -        <dt>
  1.1911 -          <var title="">service</var>
  1.1912 -           .
  1.1913 -          <code title="dom-networkservice-type">
  1.1914 -            <a href="#dom-networkservice-type">type</a>
  1.1915 -          </code>
  1.1916 -        </dt>
  1.1917 -        <dd>
  1.1918 -          <p>
  1.1919 -            The <a>valid service type</a> token value of the user-selected service.
  1.1920 -          </p>
  1.1921 -        </dd>
  1.1922 -        <dt>
  1.1923 -          <var title="">service</var>
  1.1924 -           .
  1.1925 -          <code title="dom-networkservice-url">
  1.1926 -            <a href="#dom-networkservice-url">url</a>
  1.1927 -          </code>
  1.1928 -        </dt>
  1.1929 -        <dd>
  1.1930 -          <p>
  1.1931 -            The control URL endpoint (including any required port information) of the user-selected control service that has been added to the <a>entry script origin's URL whitelist</a>.
  1.1932 -          </p>
  1.1933 -        </dd>
  1.1934 -        <dt>
  1.1935 -          <var title="">service</var>
  1.1936 -           .
  1.1937 -          <code title="dom-networkservice-config">
  1.1938 -            <a href="#dom-networkservice-config">config</a>
  1.1939 -          </code>
  1.1940 -        </dt>
  1.1941 -        <dd>
  1.1942 -          <p>
  1.1943 -            The configuration information associated with the service depending on the requested service type.
  1.1944 -          </p>
  1.1945 -        </dd>
  1.1946 -      </dl>
  1.1947 -
  1.1948 -          <p>
  1.1949 -            The <dfn id="dom-networkservice-id"><code>id</code></dfn> attribute is a unique identifier for the service. The same service provided at different times or on different objects <em class="ct">MUST</em> have the same <a href="#dom-networkservice-id"><code>id</code></a> value.
  1.1950 -         </p>
  1.1951 -
  1.1952 -         <p>
  1.1953 -            The <dfn id="dom-networkservice-name"><code>name</code></dfn> attribute represents a human-readable title for the service.
  1.1954 -         </p>
  1.1955 -
  1.1956 -         <p>
  1.1957 -             The <dfn id="dom-networkservice-type"><code>type</code></dfn> attribute reflects the value of the <a>valid service type</a> of the service.
  1.1958 -          </p>
  1.1959 -
  1.1960 -         <p>
  1.1961 -            The <dfn id="dom-networkservice-url"><code>url</code></dfn> attribute is an <a href="http://www.w3.org/TR/html5/urls.html#absolute-url" class="externalDFN">absolute URL</a> pointing to the root HTTP
  1.1962 -            endpoint for the service that has been added to the <a>entry script origin's URL whitelist</a>. Web pages can subsequently use this value for implicit cross-document messaging via various existing mechanisms (e.g. Web Sockets, Server-Sent Events, Web Messaging, XMLHttpRequest).
  1.1963 -         </p>
  1.1964 -
  1.1965 -         <p>
  1.1966 -            The <dfn id="dom-networkservice-config"><code>config</code></dfn> attribute provides the raw configuration information extracted from the given network service.
  1.1967 -         </p>
  1.1968 -
  1.1969 +        </div>
  1.1970        </section>
  1.1971 -
  1.1972 -      <section>
  1.1973 -         <h3>States</h3>
  1.1974 -
  1.1975 -      <dl class="domintro">
  1.1976 -        <dt>
  1.1977 -          <var title="">service</var>
  1.1978 -           .
  1.1979 -          <code title="dom-networkservice-online">
  1.1980 -            <a href="#dom-networkservice-online">online</a>
  1.1981 -          </code>
  1.1982 -        </dt>
  1.1983 -        <dd>
  1.1984 -          <p>
  1.1985 -            Returns <code>true</code> if the service is reporting that it is accessible on the local network or <code>false</code> if the service is reporting that it is no longer accessible (temporarily or permanently) on the local network.
  1.1986 -          </p>
  1.1987 -        </dd>
  1.1988 -      </dl>
  1.1989 -
  1.1990 +    </section>
  1.1991 +    <section>
  1.1992 +      <h3>
  1.1993 +        Events Summary
  1.1994 +      </h3>
  1.1995        <p>
  1.1996 -        The <dfn id="dom-networkservice-online"><code>online</code></dfn> attribute indicates whether the service is reporting itself as being
  1.1997 -        either <var>online</var>, and therefore accessible on the local network, in which case this attribute will return <code>true</code> or, <var>offline</var>, and therefore not accessible on the local network, either temporarily or permanently, in which case this attribute will return <code>false</code>. This attribute <em class="ct">MUST</em> default to <code>true</code>.
  1.1998 +        The following events are dispatched on the <a href="#networkservices"><code>NetworkServices</code></a> and/or
  1.1999 +        <a href="#networkservice"><code>NetworkService</code></a> objects:
  1.2000        </p>
  1.2001 -
  1.2002 -      </section>
  1.2003 -
  1.2004 -      <section>
  1.2005 -         <h3>Events</h3>
  1.2006 -
  1.2007 -      <p>
  1.2008 -         The following are the event handlers (and their corresponding event handler event types) that <em class="ct">MUST</em> be supported, as IDL attributes, by all objects implementing the
  1.2009 -         <a href="#networkservice"><code>NetworkService</code></a> interface:
  1.2010 -       </p>
  1.2011 -
  1.2012 -       <table border="1">
  1.2013 +      <table border="1"
  1.2014 +             summary="Events Summary table">
  1.2015          <thead>
  1.2016            <tr>
  1.2017              <th>
  1.2018 -              <span title="event handlers">Event handler</span>
  1.2019 -            </th>
  1.2020 -            <th>
  1.2021 -              <span>Event handler event type</span>
  1.2022 -            </th>
  1.2023 -          </tr>
  1.2024 -        </thead>
  1.2025 -        <tbody>
  1.2026 -          <tr>
  1.2027 -            <td>
  1.2028 -              <dfn id="dom-networkservice-onnotify" title="dom-NetworkService-onnotify">
  1.2029 -                <code>onnotify</code>
  1.2030 -              </dfn>
  1.2031 -            </td>
  1.2032 -            <td>
  1.2033 -              <a href="#event-notify"><code>notify</code></a>
  1.2034 -            </td>
  1.2035 -          </tr>
  1.2036 -          <tr>
  1.2037 -            <td>
  1.2038 -              <dfn id="dom-networkservice-onserviceonline" title="dom-NetworkService-onserviceonline">
  1.2039 -                <code>onserviceonline</code>
  1.2040 -              </dfn>
  1.2041 -            </td>
  1.2042 -            <td>
  1.2043 -              <a href="#event-serviceonline"><code>serviceonline</code></a>
  1.2044 -            </td>
  1.2045 -          </tr>
  1.2046 -          <tr>
  1.2047 -            <td>
  1.2048 -              <dfn id="dom-networkservice-onserviceoffline" title="dom-NetworkService-onserviceoffline">
  1.2049 -                <code>onserviceoffline</code>
  1.2050 -              </dfn>
  1.2051 -            </td>
  1.2052 -            <td>
  1.2053 -              <a href="#event-serviceoffline"><code>serviceoffline</code></a>
  1.2054 -            </td>
  1.2055 -          </tr>
  1.2056 -        </tbody>
  1.2057 -      </table>
  1.2058 -
  1.2059 -      </section>
  1.2060 -   </section>
  1.2061 -
  1.2062 -      <section>
  1.2063 -            <h2>Service Discovery</h2>
  1.2064 -
  1.2065 -      <p>
  1.2066 -         A <a>user agent</a> conforming to this specification <em class="ct">MAY</em> implement <acronym title="Simple Service Discovery Protocol">SSDP</acronym> [[!UPNP-DEVICEARCH11]] and Zeroconf [[!DNS-SD]] + [[!MDNS]] service discovery mechanisms
  1.2067 -         to enable Web pages to request and connect with HTTP services running on networked devices, discovered via either mechanism, through this API. When a <a>user agent</a> implements either of these service discovery mechanisms, then it <em class="ct">MUST</em> conform to the corresponding algorithms provided in this section of the specification.
  1.2068 -      </p>
  1.2069 -      <p>
  1.2070 -         This section presents how the results of these two service discovery
  1.2071 -         mechanisms will be matched to requested service types, how the user agent stores available and active services, how their properties are applied to any resulting <a href="#networkservice"><code>NetworkService</code></a> objects.
  1.2072 -      </p>
  1.2073 -
  1.2074 -      <p>
  1.2075 -         It is expected that user agents will perform these service discovery mechansisms asynchronously and periodically update the <a>list of networked devices</a> as required. The timing of any
  1.2076 -         service discovery mechanisms is an implementation detail left to the discretion of the implementer (e.g. once on user agent start-up, every X seconds during user agent execution or on
  1.2077 -         invocation of this API from a Web page).
  1.2078 -      </p>
  1.2079 -
  1.2080 -      <p>
  1.2081 -         The <dfn>list of available service records</dfn> is a single dynamic internal lookup table within user agents that is used to track all the  services that have been discovered and are available in the current network at any given time.
  1.2082 -         At any point during the running of either of the two service discovery mechanisms then existing entries within this table can be updated, entries can be added and entries can be removed as the status of networked
  1.2083 -         services changes according to the rules defined in this specification.
  1.2084 -      </p>
  1.2085 -
  1.2086 -      <p>
  1.2087 -        The <dfn>list of authorized service records</dfn> is a single dynamic internal lookup table within user agents that is used to track the
  1.2088 -        current services that are being shared with web pages at any given time from the <a>list of available service records</a>. Each record in the <a>list of authorized service records</a> is associated with a <var>services manager</var> object that is assigned as part of the
  1.2089 -         <a href="#dom-navigator-getnetworkservices"><code>getNetworkServices()</code></a> algorithm.
  1.2090 -      </p>
  1.2091 -
  1.2092 -      <p>
  1.2093 -        The rule for <dfn>adding an available service</dfn> is the process of adding a new service or updating an existing service in the <a>list of available service records</a> that is generally available on the user's current network. This rule takes one argument, <var>network service record</var>, and consists of
  1.2094 -        running the following steps:
  1.2095 -      </p>
  1.2096 -
  1.2097 -      <ol class="rule">
  1.2098 -
  1.2099 -        <li>
  1.2100 -          Let <var>new service registration flag</var> be <code>true</code>.
  1.2101 -        </li>
  1.2102 -
  1.2103 -        <li>
  1.2104 -           For each <var>existing service record</var> in the current <a>list of available service records</a>, run the following sub-steps:
  1.2105 -           <ol class="rule">
  1.2106 -
  1.2107 -             <li>
  1.2108 -              If the <var>existing service record</var>'s <code>id</code> property does not equal <var>network service record</var>'s <code>id</code>
  1.2109 -               property then abort any remaining sub-steps and continue at the next available <var>existing service record</var>.
  1.2110 -             </li>
  1.2111 -
  1.2112 -             <li>
  1.2113 -              Set <var>new service registration flag</var> to <code>false</code>.
  1.2114 -             </li>
  1.2115 -
  1.2116 -             <li>
  1.2117 -               Replace the value of <var>existing service record</var> in the current <a>list of available service records</a> with the value of
  1.2118 -              <var>network service record</var>.
  1.2119 -             </li>
  1.2120 -           </ol>
  1.2121 -        </li>
  1.2122 -
  1.2123 -        <li>
  1.2124 -           If <var>new service registration flag</var> is set to <code>true</code> then add <var>network service record</var> to the <a>list of available service records</a> as a new entry.
  1.2125 -        </li>
  1.2126 -
  1.2127 -        <li>
  1.2128 -          For each <var>active service</var> in the <a>list of authorized service records</a> run the following steps:
  1.2129 -
  1.2130 -          <ol class="rule">
  1.2131 -
  1.2132 -            <li>
  1.2133 -               If <var>network service record</var>'s <code>type</code> property does not equal the current <var>active service</var>'s
  1.2134 -                <code>type</code> attribute then abort any remaining sub-steps for this <var>active service</var> and continue at the next available <var>active service</var>.
  1.2135 -            </li>
  1.2136 -
  1.2137 -            <li>
  1.2138 -               If the <var>new service registration flag</var> is set to <code>true</code> then increment the <a href="#dom-networkservices-servicesavailable"><code>servicesAvailable</code></a> attribute of the <var>services manager</var> associated with
  1.2139 -               the current <var>active service</var>
  1.2140 -                object by <code>1</code> and then <a href="http://www.whatwg.org/specs/web-apps/current-work/complete/webappapis.html#queue-a-task" class="externalDFN">queue a task</a>
  1.2141 -                 to dispatch a newly created event with the name <a href="#event-serviceavailable"><code>serviceavailable</code></a> that uses the <a href="http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#event" class="externalDFN"><code>Event</code></a> interface,
  1.2142 -                 which does not bubble, is not cancellable, and has no default action, at the <var>services manager</var> associated with
  1.2143 -                 the current <var>active service</var> object.
  1.2144 -            </li>
  1.2145 -
  1.2146 -            <li>
  1.2147 -               Set <var>active service</var>'s <a href="#dom-networkservice-online"><code>online</code></a> attribute to <code>true</code> and then
  1.2148 -               <a href="http://www.whatwg.org/specs/web-apps/current-work/complete/webappapis.html#queue-a-task" class="externalDFN">queue a task</a>
  1.2149 -                to dispatch a newly created event with the name <a href="#event-serviceonline"><code>serviceonline</code></a> that uses the
  1.2150 -                <a href="http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#event" class="externalDFN"><code>Event</code></a> interface, which
  1.2151 -                 does not bubble, is not cancellable, and has no default action, at the current
  1.2152 -                <var>active service</var> object.
  1.2153 -            </li>
  1.2154 -
  1.2155 -          </ol>
  1.2156 -
  1.2157 -        </li>
  1.2158 -
  1.2159 -      </ol>
  1.2160 -
  1.2161 -
  1.2162 -      <p>
  1.2163 -        The rule for <dfn>removing an available service</dfn> is the general process of removing a service from the
  1.2164 -        <a>list of available service records</a>
  1.2165 -         that has left the user's current network or has otherwise expired. This rule takes one argument, <var>service identifier</var>, and consists of running the following steps:</p>
  1.2166 -
  1.2167 -      <ol class="rule">
  1.2168 -
  1.2169 -        <li>
  1.2170 -           For each <var>existing service record</var> in the current <a>list of available service records</a>, run the following sub-steps:
  1.2171 -           <ol class="rule">
  1.2172 -
  1.2173 -             <li>
  1.2174 -              If the <var>existing service record</var>'s <code>id</code> property does not match <var>service identifier</var> then skip any remaining sub-steps for the current <var>existing service record</var> and continue at the next available <var>existing service record</var>.
  1.2175 -             </li>
  1.2176 -
  1.2177 -             <li>
  1.2178 -               If the <var>existing service record</var>'s <code>type</code> property begins with the DOMString "<code>upnp:</code>" and
  1.2179 -               <var>existing service record</var>'s <code>eventsURL</code> property is set then run the rule to
  1.2180 -               <a>terminate an existing UPnP Events Subscription</a>, if one is currently active (as a result of having previously called
  1.2181 -               <a>setup a UPnP Events Subscription</a> against the current <var>existing service record</var>).
  1.2182 -             </li>
  1.2183 -
  1.2184 -             <li>
  1.2185 -               For each <var>active service</var> in <a>list of authorized service records</a> run the following steps:
  1.2186 -
  1.2187 -               <ol class="rule">
  1.2188 -
  1.2189 -                 <li>
  1.2190 -                    If <var>existing service record</var>'s <code>type</code> property does not equal the current <var>active service</var>'s
  1.2191 -                     <code>type</code> attribute then abort any remaining sub-steps for this <var>active service</var> and continue at the next available <var>active service</var>.
  1.2192 -                 </li>
  1.2193 -
  1.2194 -                 <li>
  1.2195 -                    Decrement the <a href="#dom-networkservices-servicesavailable"><code>servicesAvailable</code></a> attribute of the
  1.2196 -                    <var>services manager</var> associated with the current <var>active service</var>
  1.2197 -                     object by <code>1</code> and then <a href="http://www.whatwg.org/specs/web-apps/current-work/complete/webappapis.html#queue-a-task" class="externalDFN">queue a task</a>
  1.2198 -                      to dispatch a newly created event with the name <a href="#event-serviceunavailable"><code>serviceunavailable</code></a> that uses the
  1.2199 -                      <a href="http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#event" class="externalDFN"><code>Event</code></a> interface,
  1.2200 -                      which does not bubble, is not cancellable, and has no default action, at the <var>services manager</var> associated with
  1.2201 -                      the current <var>active service</var> object.
  1.2202 -                 </li>
  1.2203 -
  1.2204 -                 <li>
  1.2205 -                    Set <var>active service</var>'s <a href="#dom-networkservice-online"><code>online</code></a> attribute to <code>false</code> and then
  1.2206 -                    <a href="http://www.whatwg.org/specs/web-apps/current-work/complete/webappapis.html#queue-a-task" class="externalDFN">queue a task</a>
  1.2207 -                     to dispatch a newly created event with the name <a href="#event-serviceoffline"><code>serviceoffline</code></a> that uses the
  1.2208 -                     <a href="http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#event" class="externalDFN"><code>Event</code></a> interface, which
  1.2209 -                      does not bubble, is not cancellable, and has no default action, at the current
  1.2210 -                     <var>active service</var> object.
  1.2211 -                 </li>
  1.2212 -
  1.2213 -               </ol>
  1.2214 -
  1.2215 -             </li>
  1.2216 -
  1.2217 -             <li>
  1.2218 -               Remove <var>existing service record</var> from the current <a>list of available service records</a>.
  1.2219 -             </li>
  1.2220 -
  1.2221 -           </ol>
  1.2222 -        </li>
  1.2223 -
  1.2224 -      </ol>
  1.2225 -
  1.2226 -      <p>
  1.2227 -       User agents <em class="ct">SHOULD</em> expire a service record from the <a>list of available service records</a> when its
  1.2228 -       <code>expiryTimestamp</code> attribute exceeds the current UTC timestamp. When this condition is met the <a>user agent</a> SHOULD
  1.2229 -       run the rule for <a>removing an available service</a>, passing in the expired service record's <code>id</code> attribute as the
  1.2230 -       only argument.
  1.2231 -      </p>
  1.2232 -
  1.2233 -
  1.2234 -      <section>
  1.2235 -         <h4>Zeroconf (<abbr title="Multicast DNS">mDNS</abbr> + <abbr title="Domain Name System">DNS</abbr>-<abbr title="Service Discovery">SD</abbr>)</h4>
  1.2236 -
  1.2237 -         <p>
  1.2238 -            For each DNS response received from a user-agent-initiated Multicast DNS Browse for <abbr title="DNS Pointer Record">PTR</abbr> records with the name <code>_services._dns-sd._udp</code> on the resolved recommended automatic browsing
  1.2239 -   domain [[!MDNS]], the <a>user agent</a> <em class="ct">MUST</em> run the following steps:
  1.2240 -         </p>
  1.2241 -
  1.2242 -         <ol class="rule">
  1.2243 -
  1.2244 -            <li>Let <var>service mDNS responses</var> be an array of PTR records received by issuing a Multicast DNS Browse for PTR records with the name of the current discovered service type.</li>
  1.2245 -
  1.2246 -            <li>For each Object <var>service mDNS response</var> in <var>service mDNS responses</var>, run the following steps:
  1.2247 -               <ol>
  1.2248 -
  1.2249 -                  <li>
  1.2250 -                     Let <var>network service record</var> be an Object consisting of the following empty properties: <code>id</code>, <code>name</code>, <code>type</code>, <code>url</code>, <code>config</code>, <code>expiryTimestamp</code>.
  1.2251 -                  </li>
  1.2252 -
  1.2253 -                  <li>
  1.2254 -                     Set <var>network service record</var>'s <code>id</code> property to the value of the full PTR Service Instance Name [[!MDNS]].
  1.2255 -                  </li>
  1.2256 -
  1.2257 -                  <li>
  1.2258 -                     Set <var>network service record</var>'s <code>name</code> property to the value of the PTR Service Instance Name's <var>Instance</var> component [[!MDNS]].
  1.2259 -                  </li>
  1.2260 -
  1.2261 -                  <li>
  1.2262 -                     Set <var>network service record</var>'s <code>type</code> property to the concatenation of the string <code>zeroconf:</code> followed be the value of the PTR Service Instance Name's <var>Service</var> component [[!MDNS]].
  1.2263 -                  </li>
  1.2264 -
  1.2265 -                  <li>
  1.2266 -                     Set <var>network service record</var>'s <code>url</code> property to the resolvable Service URL obtained from performing an DNS-SD Lookup [[!DNS-SD]] of the current service from the PTR record provided [[!MDNS]].
  1.2267 -                  </li>
  1.2268 -
  1.2269 -                  <li>
  1.2270 -                     Set <var>network service record</var>'s <code>config</code> property to the string value of the contents of the first DNS-SD TXT record associated with the <var>service mDNS response</var> as defined in [[!DNS-SD]].
  1.2271 -                  </li>
  1.2272 -
  1.2273 -                  <li>
  1.2274 -                     Set <var>network service record</var>'s <code>expiryTimestamp</code> property to the value of the current date, in UTC timestamp format, plus a value of <code>120</code> seconds.
  1.2275 -                  </li>
  1.2276 -
  1.2277 -                  <li>
  1.2278 -                     Run the general rule for <a>adding an available service</a>, passing in the current <var>network service record</var> as the
  1.2279 -                     only argument.
  1.2280 -                  </li>
  1.2281 -
  1.2282 -            </ol>
  1.2283 -           </li>
  1.2284 -         </ol>
  1.2285 -
  1.2286 -      </section>
  1.2287 -
  1.2288 -      <section>
  1.2289 -         <h5>Simple Service Discovery Protocol (<abbr title="Simple Service Discovery Protocol">SSDP</abbr>)</h5>
  1.2290 -
  1.2291 -         <p>
  1.2292 -          A user agent that implements UPnP service discovery <em class="ct">MUST</em> issue an <dfn>advertisement for UPnP root devices</dfn> against the user's
  1.2293 -          current local network according to the full normative text and timing provided in 'Section 1.3.2: Search request with M-SEARCH' detailed in [[!UPNP-DEVICEARCH11]].
  1.2294 -          </p>
  1.2295 -
  1.2296 -          <p>
  1.2297 -            The user agent <em class="ct">MUST</em> issue all <a title="advertisement for UPnP root devices">advertisements for UPnP root devices</a> with a HTTP request line equal to <code>M-SEARCH * HTTP/1.1</code>, with a HOST header equal to the reserved multicast address and port of <code>239.255.255.250:1900</code>, a MAN header equal to <code>ssdp:discover</code>, an ST header equal to <code>upnp:rootdevice</code> and a user-agent defined MX header equal to a <dfn>maximum UPnP advertisement response wait time</dfn> value between <code>1</code> and <code>5</code> seconds.
  1.2298 -         </p>
  1.2299 -
  1.2300 -         <p>
  1.2301 -          The user agent <em class="ct">MUST</em> listen for incoming requests and process any incoming responses to any <a>advertisement for UPnP root devices</a> on the <dfn>standard UPnP address and port</dfn>, on all current local network interface addresses with the port <code>1900</code>, according to the rules defined in this section.
  1.2302 -         </p>
  1.2303 -
  1.2304 -         <p>
  1.2305 -          For each <dfn>HTTP Response</dfn> following an initial <a>advertisement for UPnP root devices</a> sent on a <a>standard UPnP address
  1.2306 -            and port</a> the user agent <em class="ct">MUST</em> run the following steps:
  1.2307 -         </p>
  1.2308 -
  1.2309 -         <ol class="rule">
  1.2310 -          <li>
  1.2311 -            If the <a>HTTP Response</a> is not a HTTP 200 OK response then this response is invalid and the user agent <em class="ct">MUST</em> discard this response, abort any remaining steps and return. The user agent <em class="ct">MAY</em> issue a new <a>advertisement for UPnP root devices</a> as a result of this error occurring.
  1.2312 -          </li>
  1.2313 -
  1.2314 -          <li>
  1.2315 -            If the <a>maximum UPnP advertisement response wait time</a> has been exceeded since the initial <a>advertisement for UPnP root devices</a> was sent then the <a>HTTP Response</a> is invalid and the user agent <em class="ct">MUST</em> discard this response, abort any remaining steps and return.
  1.2316 -          </li>
  1.2317 -
  1.2318 -          <li>
  1.2319 -             Let <var>ssdp device</var> be an Object with a property for each HTTP header received in the <a>HTTP Response</a>, with each key being the name of a HTTP response header and each value being that HTTP response header's value.
  1.2320 -          </li>
  1.2321 -
  1.2322 -          <li>
  1.2323 -            If <var>ssdp device</var> does not contain at least one <var>CACHE-CONTROL</var> entry, at least one <var>USN</var> entry, at least one <var>ST</var> entry and at least one <var>LOCATION</var> entry or the value of its <var>ST</var> entry is not <code>upnp:rootdevice</code>, then the <a>HTTP Response</a> is invalid and the <a>user agent</a> <em class="ct">MUST</em> discard this response, abort any remaining steps and return.
  1.2324 -          </li>
  1.2325 -
  1.2326 -          <li>
  1.2327 -            The user agent <em class="ct">MUST</em> run the rule for <a>obtaining a UPnP Device Description File</a> passing in the first occurrence of <var>LOCATION</var> from <var>ssdp device</var> as the <var>device descriptor URL</var> argument and the first occurrence of <var>USN</var> from <var>ssdp device</var> as the <var>device identifier</var> argument and the first occurrence of <var>CACHE-CONTROL</var> from <var>ssdp device</var> as the <var>device expiry</var> argument.
  1.2328 -          </li>
  1.2329 -
  1.2330 -        </ol>
  1.2331 -
  1.2332 -        <p>
  1.2333 -          For each <dfn>HTTP Request</dfn> received on a <a>standard UPnP address and port</a> the user agent <em class="ct">MUST</em> run the following steps:
  1.2334 -         </p>
  1.2335 -
  1.2336 -        <ol class="rule">
  1.2337 -
  1.2338 -          <li>
  1.2339 -            If the <a>HTTP Request</a> is not a HTTP NOTIFY request then it is not a valid UPnP Request and the user agent <em class="ct">MUST</em> return a HTTP 200 OK response, discard this request, abort any remaining steps and return.
  1.2340 -          </li>
  1.2341 -
  1.2342 -          <li>
  1.2343 -             Let <var>ssdp device</var> be an Object with a property for each HTTP header received in the <a>HTTP Request</a>, with each key being the name of a HTTP header and each value being that HTTP header's value.
  1.2344 -          </li>
  1.2345 -
  1.2346 -          <li>
  1.2347 -            If <var>ssdp device</var> does not contain at least one <var>CACHE-CONTROL</var> entry, at least one <var>USN</var> entry, at least one <var>NT</var> entry, at least one <var>NTS</var> entry and at least one <var>LOCATION</var> entry or the value of its <var>NT</var> entry is not <code>upnp:rootdevice</code>, then the <a>HTTP Request</a> is a malformed UPnP Request and the <a>user agent</a> <em class="ct">MUST</em> return a 400 Bad Request response, discard this request, abort any remaining steps and return.
  1.2348 -          </li>
  1.2349 -
  1.2350 -          <li>
  1.2351 -            If <var>ssdp device</var>'s <var>NTS</var> entry is equal to <code>ssdp:alive</code> or <code>ssdp:update</code> then the user agent <em class="ct">MUST</em> run the rule for <a>obtaining a UPnP Device Description File</a> passing in the first occurrence of <var>LOCATION</var> from <var>ssdp device</var> as the <var>device descriptor URL</var> argument and the first occurrence of <var>USN</var> from <var>ssdp device</var> as the <var>device identifier</var> argument and the first occurrence of <var>CACHE-CONTROL</var> from <var>ssdp device</var> as the <var>device expiry</var>. <br/><br/>Otherwise, if <var>ssdp device</var>'s <var>NTS</var> entry is equal to <code>ssdp:byebye</code> then the user agent <em class="ct">MUST</em> run the rule for <a>removing all services from a registered UPnP Device</a> passing in the first occurrence of <var>USN</var> from <var>ssdp device</var> as the <var>device identifier</var> argument.
  1.2352 -          </li>
  1.2353 -
  1.2354 -        </ol>
  1.2355 -
  1.2356 -      <p>
  1.2357 -        The rule for <dfn>obtaining a UPnP Device Description File</dfn> is the process of obtaining the contents of a standard UPnP Device Description [[!UPNP-DEVICEARCH11]] from a URL-based resource. This rule takes three arguments - <var>device descriptor URL</var>, <var>device identifier</var> and <var>device expiry</var> - and when called the user agent <em class="ct">MUST</em> run the following steps:
  1.2358 -      </p>
  1.2359 -
  1.2360 -      <ol class="rule">
  1.2361 -
  1.2362 -          <li>
  1.2363 -             Let <var>device descriptor file</var> contain the contents of the file located at the URL provided in <var>device descriptor URL</var> obtained according to the rules
  1.2364 -             defined in 'Section 2.11: Retrieving a description using HTTP' in [[!UPNP-DEVICEARCH11]].
  1.2365 -          </li>
  1.2366 -
  1.2367 -          <li>
  1.2368 -            If the value provided in <var>device descriptor URL</var> cannot be resolved as a reachable URL on the current network or the <var>root device descriptor file</var> remains empty then it is invalid and the <a>user agent</a> <em class="ct">MUST</em> abort any remaining steps and return.
  1.2369 -          </li>
  1.2370 -
  1.2371 -          <li>
  1.2372 -            Run the rule for <a>processing a UPnP Device Description File</a>, passing in the current <var>device descriptor file</var>, <var>device identifier</var> and <var>device expiry</var> arguments.
  1.2373 -          </li>
  1.2374 -
  1.2375 -          <li>
  1.2376 -            If the current <var>device descriptor file</var> contains a <code>&lt;deviceList&gt;</code> element then for each <code>&lt;device&gt;</code> element within <code>&lt;deviceList&gt;</code> - herein known as an <var>embedded device descriptor file</var> - the user agent <em class="ct">MUST</em>
  1.2377 -            run the rule for <a>processing a UPnP Device Description File</a>, passing in the current <var>embedded device descriptor file</var> as the <var>device descriptor file</var> argument, along with the common <var>device identifier</var> and <var>device expiry</var> arguments.
  1.2378 -          </li>
  1.2379 -
  1.2380 -      </ol>
  1.2381 -
  1.2382 -      <p>
  1.2383 -        The rule for <dfn>processing a UPnP Device Description File</dfn> is the process of parsing the contents of a standard UPnP Device Description [[!UPNP-DEVICEARCH11]] and
  1.2384 -        registering the UPnP services contained therein within the <a>list of available service records</a>.
  1.2385 -      </p>
  1.2386 -
  1.2387 -      <p>The rule for <a>processing a UPnP Device Description File</a> takes three arguments - <var>device descriptor file</var>, <var>device identifier</var> and <var>device expiry</var> - and when called the user
  1.2388 -         agent <em class="ct">MUST</em> run the following steps:</p>
  1.2389 -
  1.2390 -      <ol class="rule">
  1.2391 -
  1.2392 -          <li>
  1.2393 -             Let <var>advertised services</var> be a list of all advertised services obtained from the <var>device descriptor file</var> containing the value of the first occurrence of the <code>&lt;serviceList&gt;</code> element as it is defined in 'Section 2.3: Device Description' in [[!UPNP-DEVICEARCH11]].
  1.2394 -          </li>
  1.2395 -
  1.2396 -          <li>
  1.2397 -             For each <code>&lt;service&gt;</code> element - known as an <var>advertised service</var> - in <var>advertised services</var> run the following steps:
  1.2398 -
  1.2399 -             <ol class="rule">
  1.2400 -
  1.2401 -                <li>
  1.2402 -                   Let <var>network service record</var> be a new Object consisting of the following empty properties: <code>id</code>, <code>deviceId</code>, <code>name</code>, <code>type</code>, <code>url</code>, <code>eventsUrl</code>, <code>config</code>, <code>expiryTimestamp</code>.
  1.2403 -                </li>
  1.2404 -
  1.2405 -                <li>
  1.2406 -                   Set <var>network service record</var>'s <code>id</code> property to the concatenated string value of <var>device identifier</var> with the <var>advertised service</var>'s <code>&lt;serviceId&gt;</code> sub-element.
  1.2407 -                </li>
  1.2408 -
  1.2409 -                <li>
  1.2410 -                   Set <var>network service record</var>'s <code>deviceId</code> property to the value of <var>device identifier</var>.
  1.2411 -                </li>
  1.2412 -
  1.2413 -                <li>
  1.2414 -                   Set <var>network service record</var>'s <code>name</code> property to the string value of the first occurrence of the <var>advertised service</var>'s <code>&lt;serviceId&gt;</code> sub-element.
  1.2415 -                </li>
  1.2416 -
  1.2417 -                <li>
  1.2418 -                   Set <var>network service record</var>'s <code>type</code> property to the concatenation of the string <code>upnp:</code> followed by the string value of the first occurrence of the <var>advertised service</var>'s <code>&lt;serviceType&gt;</code> sub-element.
  1.2419 -                </li>
  1.2420 -
  1.2421 -                <li>
  1.2422 -                   Set <var>network service record</var>'s <code>url</code> property to the string value of the first occurrence of the <var>advertised service</var>'s <code>&lt;controlURL&gt;</code> sub-element.
  1.2423 -                </li>
  1.2424 -
  1.2425 -                <li>
  1.2426 -                   Set <var>network service record</var>'s <code>config</code> property to the string value of the contents of the first occurrence of the <code>&lt;device&gt;</code> element in the <var>device descriptor file</var>.
  1.2427 -                </li>
  1.2428 -
  1.2429 -                <li>
  1.2430 -                   If <var>advertised service</var>'s <code>&lt;eventSubURL&gt;</code> sub-element is not empty, then set <var>network service record</var>'s <code>eventsUrl</code> property to the string value of the first occurrence of the <var>advertised service</var>'s <code>&lt;eventSubURL&gt;</code> sub-element. Otherwise, do not set <var>network service record</var>'s <code>eventsUrl</code> property.
  1.2431 -                </li>
  1.2432 -
  1.2433 -                <li>
  1.2434 -                   Set <var>network service record</var>'s <code>expiryTimestamp</code> property to the value of the current date, in UTC timestamp format, plus the value of <var>device expiry</var>.
  1.2435 -                </li>
  1.2436 -
  1.2437 -                <li>
  1.2438 -                  Run the general rule for <a>adding an available service</a>, passing in the current <var>network service record</var> as the only argument.
  1.2439 -                </li>
  1.2440 -
  1.2441 -              </ol>
  1.2442 -
  1.2443 -          </ol>
  1.2444 -
  1.2445 -         <p>
  1.2446 -           The rule for <dfn>removing all services from a registered UPnP Device</dfn> is the process of removing all services associated with a
  1.2447 -           device from the <a>list of available service records</a> that has left the user's current network or has otherwise timed out or expired.
  1.2448 -           This rule takes one argument, <var>device identifier</var>, and consists of running the following steps:
  1.2449 -        </p>
  1.2450 -
  1.2451 -         <ol class="rule">
  1.2452 -
  1.2453 -           <li>
  1.2454 -              For each <var>existing service record</var> in the current <a>list of available service records</a>, run the following sub-steps:
  1.2455 -              <ol class="rule">
  1.2456 -
  1.2457 -                <li>
  1.2458 -                 If the <var>existing service record</var>'s <code>deviceId</code> property does not match <var>device identifier</var> then skip any remaining sub-steps for the current <var>existing service record</var> and continue at the next available <var>existing service record</var>.
  1.2459 -                </li>
  1.2460 -
  1.2461 -                <li>
  1.2462 -                  Run the general rule for <a>removing an available service</a> passing in <var>existing service record</var>'s <code>id</code>
  1.2463 -                  property as the only argument.
  1.2464 -                </li>
  1.2465 -
  1.2466 -              </ol>
  1.2467 -           </li>
  1.2468 -
  1.2469 -         </ol>
  1.2470 -
  1.2471 -         <p>When the <a>user agent</a> is to <dfn>setup a UPnP Events Subscription</dfn>, it is to run the following steps with the current <var>network service record</var> object as defined in 'Section 4.1.2: SUBSCRIBE with NT and CALLBACK' in [[!UPNP-DEVICEARCH11]]:</p>
  1.2472 -
  1.2473 -         <ol class="rule">
  1.2474 -            <li>
  1.2475 -               If <var>network service record</var>'s <code>eventsUrl</code> property is empty then the <a>user agent</a> <em class="ct">MUST</em> abort these steps.
  1.2476 -            </li>
  1.2477 -
  1.2478 -            <li>
  1.2479 -               Let <var>callback URL</var> be the value of creating a new <a>user-agent generated callback url</a>.
  1.2480 -            </li>
  1.2481 -
  1.2482 -            <li>
  1.2483 -               Send a HTTP SUBSCRIBE request with a <em>NT</em> header with a string value of <code>upnp:event</code>, a <em>TIMEOUT</em> header with a user-agent defined timeout value (in the form <code>Second-XX</code> where <code>XX</code> is the user-agent defined timeout value in seconds) and a <em>CALLBACK</em> header
  1.2484 -               with a string value of <var>callback URL</var> towards the <var>network service record</var>'s <code>eventsUrl</code> property.
  1.2485 -            </li>
  1.2486 -
  1.2487 -            <li>
  1.2488 -               If a non-200 OK response is received from the HTTP SUBSCRIBE request then the <a>user agent</a> <em class="ct">MUST</em> abort these steps.
  1.2489 -            </li>
  1.2490 -
  1.2491 -            <li>
  1.2492 -               On receiving a valid 200 OK response, run the following steps:
  1.2493 -
  1.2494 -               <ol class="rule">
  1.2495 -                  <li>
  1.2496 -                     Let <var>callback ID</var> equal the string value of the first included <em>SID</em> header, if it exists.
  1.2497 -                  </li>
  1.2498 -                  <li>
  1.2499 -                     Let <var>timeout date</var> equal the sum of the current UTC date value plus the integer value of the first included <em>TIMEOUT</em> header (minus the leading string of <code>Second-</code>), if it exists.
  1.2500 -                  </li>
  1.2501 -                  <li>
  1.2502 -                     Run the following steps aynchronously and continue to the step labeled <em>listen</em> below.
  1.2503 -                  </li>
  1.2504 -                  <li>
  1.2505 -                     <em>Refresh Subscription</em>: Run the following steps at a set interval (X) within the <a>user agent</a>:
  1.2506 -
  1.2507 -                     <ol class="rule">
  1.2508 -                        <li>
  1.2509 -                           Let <var>current date</var> equal the current UTC date.
  1.2510 -                        </li>
  1.2511 -                        <li>
  1.2512 -                           If <var>current date</var> is less than the <var>timeout date</var> then continue to the step labeled <em>refresh subscription</em> above.
  1.2513 -                        </li>
  1.2514 -                        <li>
  1.2515 -                           Send a HTTP SUBSCRIBE request with a <em>SID</em> header with the string value of <var>callback ID</var> and a user-agent defined <em>TIMEOUT</em> header (in the form <code>Second-XX</code> where <code>XX</code> is the user-agent defined timeout value in seconds) towards the <var>network service record</var>'s <code>eventsUrl</code> property.
  1.2516 -                        </li>
  1.2517 -                        <li>
  1.2518 -                           On receiving a valid 200 OK, update <var>callback ID</var> with the string value of the first included <em>SID</em> header, if it exists. All other HTTP
  1.2519 -                           responses should cause the <a>user agent</a> to continue from the step labeled <em>refresh subscription</em> above.
  1.2520 -                        </li>
  1.2521 -                     </ol>
  1.2522 -
  1.2523 -                  </li>
  1.2524 -
  1.2525 -                  <li>
  1.2526 -                     <em>Listen</em>: For each HTTP NOTIFY request received at the <var>callback URL</var> the <a>user agent</a> is to run the following steps:
  1.2527 -
  1.2528 -                     <ol class="rule">
  1.2529 -                        <li>
  1.2530 -                           Let <var>content clone</var> be the result of obtaining the message body of the HTTP NOTIFY request. If <var>content clone</var> is empty, then the <a>user agent</a> <em class="ct">MUST</em> abort these steps.
  1.2531 -                        </li>
  1.2532 -                        <li>
  1.2533 -                          Let <var>notification event</var> be a new simple event that uses the
  1.2534 -                          <a href="http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#event" class="externalDFN"><code>Event</code></a>
  1.2535 -                           interface with the name <a href="#event-notify"><code>notify</code></a>,
  1.2536 -                           which does not bubble, is not cancellable, and has no default action.
  1.2537 -                        </li>
  1.2538 -                        <li>
  1.2539 -                           Let the <code>data</code> attribute of <var>notification event</var> have the DOMString value of <var>content clone</var>.
  1.2540 -                        </li>
  1.2541 -                        <li>
  1.2542 -                           <a href="http://www.whatwg.org/specs/web-apps/current-work/complete/webappapis.html#queue-a-task" class="externalDFN">Queue a task</a> to
  1.2543 -                            dispatch <var>notification event</var> at the current <a><code>NetworkService</code></a> object.
  1.2544 -                        </li>
  1.2545 -                     </ol>
  1.2546 -                  </li>
  1.2547 -
  1.2548 -               </ol>
  1.2549 -
  1.2550 -            </li>
  1.2551 -         </ol>
  1.2552 -
  1.2553 -         <p>
  1.2554 -           A <a>user agent</a> can <dfn>terminate an existing UPnP Events Subscription</dfn> at any time for any <var>active service</var> in the <a>list of authorized service records</a> by sending an HTTP UNSUBSCRIBE request - as defined in 'Section 4.1.4: Canceling a subscription with UNSUBSCRIBE' in [[!UPNP-DEVICEARCH11]] - with a HOST header set to that <var>active service</var>'s <code>eventsUrl</code> property and a SID header set to the <var>callback ID</var> obtained when the initial <a>setup a UPnP Events Subscription</a> action occurred.
  1.2555 -         </p>
  1.2556 -
  1.2557 -         </section>
  1.2558 -
  1.2559 -         <section>
  1.2560 -            <h3>Network Topology Monitoring</h3>
  1.2561 -
  1.2562 -                  <div>
  1.2563 -                     <p>
  1.2564 -                        When the <a>user agent</a> detects that the user has dropped from their connected network then, for each <var>existing service record</var> in the <a>list of available service records</a>, the user agent
  1.2565 -                        <em class="ct">MUST</em>
  1.2566 -                            run the general rule for <a>removing an available service</a> passing in each <var>existing service record</var>'s
  1.2567 -                            <code>id</code> property as the only argument for each call.
  1.2568 -                    </p>
  1.2569 -
  1.2570 -                     <p>
  1.2571 -                        When the <a>user agent</a> detects that the user has connected to a new network or reconnected to an existing network, then it
  1.2572 -                        <em class="ct">SHOULD</em> restart its discovery
  1.2573 -                         mechanisms as defined in the <a href="#service-discovery">Service Discovery</a> section of this specification, maintaining
  1.2574 -                         the existing <a>list of authorized service records</a> currently in use.
  1.2575 -                     </p>
  1.2576 -                  </div>
  1.2577 -         </section>
  1.2578 -      </section>
  1.2579 -
  1.2580 -  <section>
  1.2581 -      <h3>Events Summary</h3>
  1.2582 -
  1.2583 -      <p>The following events are dispatched on the <a href="#networkservices"><code>NetworkServices</code></a> and/or <a href="#networkservice"><code>NetworkService</code></a> objects:</p>
  1.2584 -
  1.2585 -       <table border="1">
  1.2586 -        <thead>
  1.2587 -          <tr>
  1.2588 -            <th>
  1.2589 -              <span title="event handlers">Event name</span>
  1.2590 +              <span>Event name</span>
  1.2591              </th>
  1.2592              <th>
  1.2593                <span>Interface</span>
  1.2594 @@ -1431,12 +1473,11 @@
  1.2595          <tbody>
  1.2596            <tr>
  1.2597              <td>
  1.2598 -              <dfn id="event-serviceavailable">
  1.2599 -                <code>serviceavailable</code>
  1.2600 -              </dfn>
  1.2601 +              <dfn id="event-serviceavailable"><code>serviceavailable</code></dfn>
  1.2602              </td>
  1.2603              <td>
  1.2604 -              <a href="http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#event" class="externalDFN"><code>Event</code></a>
  1.2605 +              <a href="http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#event"
  1.2606 +                  class="externalDFN"><code>Event</code></a>
  1.2607              </td>
  1.2608              <td>
  1.2609                When a new service that matches one of the <a>requested type tokens</a> is found in the current network.
  1.2610 @@ -1444,25 +1485,24 @@
  1.2611            </tr>
  1.2612            <tr>
  1.2613              <td>
  1.2614 -              <dfn id="event-serviceunavailable">
  1.2615 -                <code>serviceunavailable</code>
  1.2616 -              </dfn>
  1.2617 +              <dfn id="event-serviceunavailable"><code>serviceunavailable</code></dfn>
  1.2618              </td>
  1.2619              <td>
  1.2620 -              <a href="http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#event" class="externalDFN"><code>Event</code></a>
  1.2621 +              <a href="http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#event"
  1.2622 +                  class="externalDFN"><code>Event</code></a>
  1.2623              </td>
  1.2624              <td>
  1.2625 -              When an existing service that matches one of the <a>requested type tokens</a> gracefully leaves or expires from the current network.
  1.2626 +              When an existing service that matches one of the <a>requested type tokens</a> gracefully leaves or
  1.2627 +              expires from the current network.
  1.2628              </td>
  1.2629            </tr>
  1.2630            <tr>
  1.2631              <td>
  1.2632 -              <dfn id="event-serviceonline">
  1.2633 -                <code>serviceonline</code>
  1.2634 -              </dfn>
  1.2635 +              <dfn id="event-serviceonline"><code>serviceonline</code></dfn>
  1.2636              </td>
  1.2637              <td>
  1.2638 -              <a href="http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#event" class="externalDFN"><code>Event</code></a>
  1.2639 +              <a href="http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#event"
  1.2640 +                  class="externalDFN"><code>Event</code></a>
  1.2641              </td>
  1.2642              <td>
  1.2643                When a current service renews its service registration within the current network.
  1.2644 @@ -1470,12 +1510,11 @@
  1.2645            </tr>
  1.2646            <tr>
  1.2647              <td>
  1.2648 -              <dfn id="event-serviceoffline">
  1.2649 -                <code>serviceoffline</code>
  1.2650 -              </dfn>
  1.2651 +              <dfn id="event-serviceoffline"><code>serviceoffline</code></dfn>
  1.2652              </td>
  1.2653              <td>
  1.2654 -              <a href="http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#event" class="externalDFN"><code>Event</code></a>
  1.2655 +              <a href="http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#event"
  1.2656 +                  class="externalDFN"><code>Event</code></a>
  1.2657              </td>
  1.2658              <td>
  1.2659                When a current service gracefully leaves or otherwise expires from the current network.
  1.2660 @@ -1483,115 +1522,132 @@
  1.2661            </tr>
  1.2662            <tr>
  1.2663              <td>
  1.2664 -              <dfn id="event-notify">
  1.2665 -                <code>notify</code>
  1.2666 -              </dfn>
  1.2667 +              <dfn id="event-notify"><code>notify</code></dfn>
  1.2668              </td>
  1.2669              <td>
  1.2670 -              <a href="http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#event" class="externalDFN"><code>Event</code></a>
  1.2671 +              <a href="http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#event"
  1.2672 +                  class="externalDFN"><code>Event</code></a>
  1.2673              </td>
  1.2674              <td>
  1.2675 -              When a valid UPnP Events Subscription Message is received on a <a>user-agent generated callback url</a> for a current service. This event never fires for Zeroconf-based services.
  1.2676 +              When a valid UPnP Events Subscription Message is received on a <a>user-agent generated callback url</a>
  1.2677 +              for a current service. This event never fires for Zeroconf-based services.
  1.2678              </td>
  1.2679            </tr>
  1.2680          </tbody>
  1.2681        </table>
  1.2682 -
  1.2683 -  </section>
  1.2684 -
  1.2685 -   <section>
  1.2686 -      <h3>Garbage collection</h3>
  1.2687 -
  1.2688 +    </section>
  1.2689 +    <section>
  1.2690 +      <h3>
  1.2691 +        Garbage collection
  1.2692 +      </h3>
  1.2693        <p>
  1.2694 -         Only when the user navigates away from the current browsing context can <a><code>NetworkService</code></a> objects be garbage-collected, its records in the <a>entry script origin's URL whitelist</a> be removed and its corresponding entry in the <a>list of authorized service records</a> be removed according to passing each expired object identifier through the rule for <a>removing an available service</a>.
  1.2695 +        Only when the user navigates away from the current browsing context can <a><code>NetworkService</code></a>
  1.2696 +        objects be garbage-collected, its records in the <a>entry script origin's URL whitelist</a> be removed and its
  1.2697 +        corresponding entry in the <a>list of authorized service records</a> be removed according to passing each
  1.2698 +        expired object identifier through the rule for <a>removing an available service</a>.
  1.2699        </p>
  1.2700 -
  1.2701 -   </section>
  1.2702 -
  1.2703 -
  1.2704 +    </section>
  1.2705      <section>
  1.2706 -      <h3>Use Cases and Requirements</h3>
  1.2707 -
  1.2708 -      <p>This section covers what the requirements are for this API, as well as illustrates some use cases.</p>
  1.2709 -
  1.2710 +      <h3>
  1.2711 +        Use Cases and Requirements
  1.2712 +      </h3>
  1.2713 +      <p>
  1.2714 +        This section covers what the requirements are for this API, as well as illustrates some use cases.
  1.2715 +      </p>
  1.2716        <ul class="rule">
  1.2717 -         <li>
  1.2718 -            Once a user has given permission, user agents should provide the ability for Web pages to communicate directly with a Local-networked Service.
  1.2719 -            <ul class="rule">
  1.2720 -               <li>
  1.2721 -                  Example: A web-based TV remote control. A Web page wants to control the current user's TV, changing the programming shown or increasing/decreasing/muting the
  1.2722 -                  volume of the Local-networked Device. The Web page requests a service type that is known to be implemented by television sets to which it has the
  1.2723 -                  application logic to communicate. Local devices providing the request service types are discovered and presented to the user for authorization. The user selects one
  1.2724 -                  or more of the discovered television sets to be accessible to the current Web page and then clicks 'Share'. The Web page can now communicate directly with
  1.2725 -                  the user-authorized Local-networked services.
  1.2726 -               </li>
  1.2727 -            </ul>
  1.2728 -         </li>
  1.2729 -
  1.2730 -         <li>
  1.2731 -           Web pages should be able to communicate with Local-networked Services using the messaging channel supported by those Devices.
  1.2732 -           <ul class="rule">
  1.2733 -            <li>
  1.2734 -               Example: A Web page advertises that it is capable of controlling multiple Home Media Servers. The user can select their Home Media Server type from a drop-down list, at which point the
  1.2735 -               Web page sends a request to the user agent to connect with the associated service type of the Home Media Server. The Media Server selected implements a Web Socket channel for
  1.2736 -               bi-directional service communication and so the Web page opens a web socket to the requested Media Server and can communicate as required via that appropriate channel.
  1.2737 +        <li>Once a user has given permission, user agents should provide the ability for Web pages to communicate
  1.2738 +        directly with a Local-networked Service.
  1.2739 +          <ul class="rule">
  1.2740 +            <li>Example: A web-based TV remote control. A Web page wants to control the current user's TV, changing the
  1.2741 +            programming shown or increasing/decreasing/muting the volume of the Local-networked Device. The Web page
  1.2742 +            requests a service type that is known to be implemented by television sets to which it has the application
  1.2743 +            logic to communicate. Local devices providing the request service types are discovered and presented to the
  1.2744 +            user for authorization. The user selects one or more of the discovered television sets to be accessible to
  1.2745 +            the current Web page and then clicks 'Share'. The Web page can now communicate directly with the
  1.2746 +            user-authorized Local-networked services.
  1.2747              </li>
  1.2748 -           </ul>
  1.2749 -         </li>
  1.2750 -
  1.2751 -         <li>
  1.2752 -           Web pages should be able to communicate with Local-networked Services using the messaging format supported by those Devices.
  1.2753 -           <ul class="rule">
  1.2754 -            <li>
  1.2755 -               Example: A Web page advertises that it is capable of interacting with and controlling multiple types of Home Media Server. The user can select their Home Media Server type from a drop-down list or known Media Servers, at which point the
  1.2756 -               Web page sends a request to the user agent to connect with the associated service type (and, optionally, the associated event type) of the Home Media Server. The communiciation protocols supported by Home Media Servers typically vary
  1.2757 -               between UPnP, JSON-RPC, Protocol Buffers or other messaging formats depending on the Home Media Server requested. The Web page is able to communicate with the user-selected Home Media
  1.2758 -               Server in the messaging format supported by that Device, which, in this example is a simple key/value pair text format.
  1.2759 +          </ul>
  1.2760 +        </li>
  1.2761 +        <li>Web pages should be able to communicate with Local-networked Services using the messaging channel supported
  1.2762 +        by those Devices.
  1.2763 +          <ul class="rule">
  1.2764 +            <li>Example: A Web page advertises that it is capable of controlling multiple Home Media Servers. The user
  1.2765 +            can select their Home Media Server type from a drop-down list, at which point the Web page sends a request
  1.2766 +            to the user agent to connect with the associated service type of the Home Media Server. The Media Server
  1.2767 +            selected implements a Web Socket channel for bi-directional service communication and so the Web page opens
  1.2768 +            a web socket to the requested Media Server and can communicate as required via that appropriate channel.
  1.2769              </li>
  1.2770 -           </ul>
  1.2771 -         </li>
  1.2772 -
  1.2773 -         <li>
  1.2774 -           Web pages should not be able to communicate with Local-networked Services that have not been authorized by the user thereby maintaining the user's privacy.
  1.2775 -           <ul class="rule">
  1.2776 -            <li>
  1.2777 -               Example: A Web page requests access to one type of Local-networked service. The user authorizes access to that particular service. Other services running on that same device, and on other devices
  1.2778 -               within the network, should not be accessible to the current Web page.
  1.2779 +          </ul>
  1.2780 +        </li>
  1.2781 +        <li>Web pages should be able to communicate with Local-networked Services using the messaging format supported
  1.2782 +        by those Devices.
  1.2783 +          <ul class="rule">
  1.2784 +            <li>Example: A Web page advertises that it is capable of interacting with and controlling multiple types of
  1.2785 +            Home Media Server. The user can select their Home Media Server type from a drop-down list or known Media
  1.2786 +            Servers, at which point the Web page sends a request to the user agent to connect with the associated
  1.2787 +            service type (and, optionally, the associated event type) of the Home Media Server. The communiciation
  1.2788 +            protocols supported by Home Media Servers typically vary between UPnP, JSON-RPC, Protocol Buffers or other
  1.2789 +            messaging formats depending on the Home Media Server requested. The Web page is able to communicate with
  1.2790 +            the user-selected Home Media Server in the messaging format supported by that Device, which, in this
  1.2791 +            example is a simple key/value pair text format.
  1.2792              </li>
  1.2793 -           </ul>
  1.2794 -         </li>
  1.2795 -
  1.2796 -         <li>
  1.2797 -           A user should be able to share one or more Local-networked Services based on a particular service type request from a Web page.
  1.2798 -           <ul class="rule">
  1.2799 -            <li>
  1.2800 -               Example: A Web page is capable of interacting with a specific profile of Local-networked Service. As such, it makes a request to the user agent to access those services, of which multiple matches
  1.2801 -               are found. The user is capable of selecting one or more of the discovered services to share with the Web page. The Web page can then implement a drag-and-drop interface for the user to drag specific
  1.2802 -               actions on to one or more of the authorized Local-networked Services.
  1.2803 +          </ul>
  1.2804 +        </li>
  1.2805 +        <li>Web pages should not be able to communicate with Local-networked Services that have not been authorized by
  1.2806 +        the user thereby maintaining the user's privacy.
  1.2807 +          <ul class="rule">
  1.2808 +            <li>Example: A Web page requests access to one type of Local-networked service. The user authorizes access
  1.2809 +            to that particular service. Other services running on that same device, and on other devices within the
  1.2810 +            network, should not be accessible to the current Web page.
  1.2811              </li>
  1.2812 -           </ul>
  1.2813 -         </li>
  1.2814 -
  1.2815 -         <li>
  1.2816 -           User agents should provide an API exposed to script that exposes the features above. The user is notified by UI anytime interaction with Local-networked Services is requested, giving the user
  1.2817 -           full ability to cancel or abort the transaction. The user selects the Local-networked Services to be connected to the current Web page, and can cancel these at any time. No invocations to
  1.2818 -           these APIs occur silently without user intervention.
  1.2819 -         </li>
  1.2820 +          </ul>
  1.2821 +        </li>
  1.2822 +        <li>A user should be able to share one or more Local-networked Services based on a particular service type
  1.2823 +        request from a Web page.
  1.2824 +          <ul class="rule">
  1.2825 +            <li>Example: A Web page is capable of interacting with a specific profile of Local-networked Service. As
  1.2826 +            such, it makes a request to the user agent to access those services, of which multiple matches are found.
  1.2827 +            The user is capable of selecting one or more of the discovered services to share with the Web page. The Web
  1.2828 +            page can then implement a drag-and-drop interface for the user to drag specific actions on to one or more
  1.2829 +            of the authorized Local-networked Services.
  1.2830 +            </li>
  1.2831 +          </ul>
  1.2832 +        </li>
  1.2833 +        <li>User agents should provide an API exposed to script that exposes the features above. The user is notified
  1.2834 +        by UI anytime interaction with Local-networked Services is requested, giving the user full ability to cancel or
  1.2835 +        abort the transaction. The user selects the Local-networked Services to be connected to the current Web page,
  1.2836 +        and can cancel these at any time. No invocations to these APIs occur silently without user intervention.
  1.2837 +        </li>
  1.2838        </ul>
  1.2839      </section>
  1.2840 +    <section class="informative appendix">
  1.2841 +      <h3>
  1.2842 +        Examples
  1.2843 +      </h3>
  1.2844 +      <div class="example">
  1.2845 +        <p>
  1.2846 +          This sample code exposes a button. When clicked, this button is disabled and the user is prompted to offer a
  1.2847 +          network service. The user may also select multiple network services. When the user has authorized a network
  1.2848 +          service to be connected to the web page then the web page issues a simple command to get a list of all the
  1.2849 +          albums stored on the connected media player service.
  1.2850 +        </p>
  1.2851 +        <p>
  1.2852 +          The button is re-enabled only when the connected network service disconnects for whatever reason (the service
  1.2853 +          becomes unavailable on the network, the user disconnects from their current network or the user revokes
  1.2854 +          access to the service from the current web page). At this point the user can re-click the button to select a
  1.2855 +          new network service to connect to the web page and the above steps are repeated.
  1.2856 +        </p>
  1.2857 +        <p>
  1.2858 +          The provided service type identifier and service interaction used in this example is based on the
  1.2859 +          well-defined service type and messaging format supported by the <a href="http://xbmc.org/about/">XBMC Media
  1.2860 +          Server</a>.
  1.2861 +        </p>
  1.2862 +        <hr>
  1.2863 +        <pre class="highlight">
  1.2864 +&lt;input type="button" value="Start" onclick="start()" id="startBtn"/&gt;
  1.2865 +&lt;div id="debugconsole"&gt;&lt;/div&gt;
  1.2866  
  1.2867 -          <section class="informative appendix">
  1.2868 -             <h3>Examples</h3>
  1.2869 -
  1.2870 -           <div class="example">
  1.2871 -            <p>This sample code exposes a button. When clicked, this button is disabled and the user is prompted to offer a network service. The user may also select multiple network services. When the user has authorized a network service to be connected to the web page then the web page issues a simple command to get a list of all the albums stored on the connected media player service.
  1.2872 -            <p>The button is re-enabled only when the connected network service disconnects for whatever reason (the service becomes unavailable on the network, the user disconnects from their current network or the user revokes access to the service from the current web page). At this point the user can re-click the button to select a new network service to connect to the web page and the above steps are repeated.</p>
  1.2873 -            <p>The provided service type identifier and service interaction used in this example is based on the well-defined service type and messaging format supported by the <a href="http://xbmc.org/about/">XBMC Media Server</a>. </p>
  1.2874 -            <hr />
  1.2875 -            <pre class="highlight">&lt;input type="button" value="Start" onclick="start()" id="startBtn"/&gt;
  1.2876 -&lt;div id="debugconsole">&lt;/div>
  1.2877 -
  1.2878 -&lt;script>
  1.2879 +&lt;script&gt;
  1.2880   var startBtn = document.getElementById('startBtn'),
  1.2881       debug = document.getElementById('debugconsole');
  1.2882  
  1.2883 @@ -1609,7 +1665,7 @@
  1.2884  // Listen for service disconnect messages
  1.2885  
  1.2886     services[0].addEventListener('serviceoffline', function ( e ) {
  1.2887 -       debug.innerHTML += "&lt;br>" + services[0].name + " disconnected.";
  1.2888 +       debug.innerHTML += "&lt;br&gt;" + services[0].name + " disconnected.";
  1.2889         startBtn.disabled = false;
  1.2890     }, false);
  1.2891  
  1.2892 @@ -1625,7 +1681,7 @@
  1.2893     svcXhr.addEventListener('readystatechange', function ( response ) {
  1.2894       if( response.readyState != 4 || response.status != 200 )
  1.2895          return;
  1.2896 -     debug.innerHTML += "&lt;br>" + services[0].name + " response received: ";
  1.2897 +     debug.innerHTML += "&lt;br&gt;" + services[0].name + " response received: ";
  1.2898       debug.textContent += JSON.parse(response.responseText);
  1.2899     }, false);
  1.2900  
  1.2901 @@ -1635,28 +1691,33 @@
  1.2902     ];
  1.2903  
  1.2904     svcXhr.send(JSON.stringify(svcMsg));
  1.2905 -   debug.innerHTML += "&lt;br>" + services[0].name + " request sent: ";
  1.2906 +   debug.innerHTML += "&lt;br&gt;" + services[0].name + " request sent: ";
  1.2907     debug.textContent += JSON.stringify(svcMsg);
  1.2908  
  1.2909   }
  1.2910  
  1.2911   function error( err ) {
  1.2912 -   debug.innerHTML += "&lt;br>An error occurred obtaining a local network service.";
  1.2913 +   debug.innerHTML += "&lt;br&gt;An error occurred obtaining a local network service.";
  1.2914     startBtn.disabled = false;
  1.2915   }
  1.2916 -&lt;/script></pre>
  1.2917 -           </div>
  1.2918 -
  1.2919 -           <div class="example">
  1.2920 -            <p>
  1.2921 -             This sample exposes a drop-down list containing a number of common Home-based audio devices. When the user selects an audio device from the list provided, they are prompted to authorize a network service
  1.2922 -             based on the service type requested. The user may also select multiple network services matching the selected service type.
  1.2923 -             In this example, the user selects their make as being <var>Sony</var> and their model as being <var>Bravia S1000</var> from which the Web page can derive a service type
  1.2924 -             (<var>urn:schemas-upnp-org:service:RenderingControl:1</var>).
  1.2925 -             <br /><br />Once the user has authorized the device, the web page sends a simple mute command according to the messaging format supported by the device.
  1.2926 -            </p>
  1.2927 -            <hr />
  1.2928 -            <pre class="highlight">&lt;select name="make" id="make"&gt;
  1.2929 +&lt;/script&gt;
  1.2930 +</pre>
  1.2931 +      </div>
  1.2932 +      <div class="example">
  1.2933 +        <p>
  1.2934 +          This sample exposes a drop-down list containing a number of common Home-based audio devices. When the user
  1.2935 +          selects an audio device from the list provided, they are prompted to authorize a network service based on the
  1.2936 +          service type requested. The user may also select multiple network services matching the selected service
  1.2937 +          type. In this example, the user selects their make as being <var>Sony</var> and their model as being
  1.2938 +          <var>Bravia S1000</var> from which the Web page can derive a service type
  1.2939 +          (<var>urn:schemas-upnp-org:service:RenderingControl:1</var>).<br>
  1.2940 +          <br>
  1.2941 +          Once the user has authorized the device, the web page sends a simple mute command according to the messaging
  1.2942 +          format supported by the device.
  1.2943 +        </p>
  1.2944 +        <hr>
  1.2945 +        <pre class="highlight">
  1.2946 +&lt;select name="make" id="make"&gt;
  1.2947    &lt;option selected="selected" disabled="disabled"&gt;Select make&lt;/option&gt;
  1.2948    &lt;option&gt;Sony&lt;/option&gt;
  1.2949    &lt;option&gt;Philips&lt;/option&gt;
  1.2950 @@ -1688,7 +1749,7 @@
  1.2951      defaultOption.setAttribute("disabled", "disabled");
  1.2952      defaultOption.setAttribute("selected", "selected");
  1.2953      modelEl.appendChild(defaultOption);
  1.2954 -    for(var i = 0, l = models[makeEl.value].length; i < l; i++) {
  1.2955 +    for(var i = 0, l = models[makeEl.value].length; i &lt; l; i++) {
  1.2956        var option = document.createElement("option");
  1.2957        option.textContent = models[makeEl.value][i]["name"];
  1.2958        option.setAttribute("value", models[makeEl.value][i]["type"] + ":" + models[makeEl.value][i]["service"]);
  1.2959 @@ -1697,7 +1758,7 @@
  1.2960    }, false);
  1.2961  
  1.2962    modelEl.addEventListener('change', function() {
  1.2963 -    if(navigator.getNetworkServices &&
  1.2964 +    if(navigator.getNetworkServices &amp;&amp;
  1.2965           modelEl.value == "upnp:urn:schemas-upnp-org:service:RenderingControl:1") {
  1.2966        navigator.getNetworkServices(modelEl.value, successCallback, errorCallback);
  1.2967      } else if (modelEl.value == "zeroconf:_mediarenderer._http._tcp") {
  1.2968 @@ -1714,7 +1775,7 @@
  1.2969    // Listen for service push notification messages
  1.2970  
  1.2971      services[0].addEventListener('notify', function ( msg ) {
  1.2972 -         debug.innerHTML += "&lt;br>" + services[0].name + " event received: ";
  1.2973 +         debug.innerHTML += "&lt;br&gt;" + services[0].name + " event received: ";
  1.2974           debug.textContent += msg.data;
  1.2975      }, false);
  1.2976  
  1.2977 @@ -1757,21 +1818,27 @@
  1.2978    function errorCallback( error ) {
  1.2979      debug.innerHTML += "&lt;br&gt;An error occurred: " + error.code;
  1.2980    }
  1.2981 -&lt;/script&gt;</pre>
  1.2982 -          </div>
  1.2983 -
  1.2984 -       </section>
  1.2985 -
  1.2986 +&lt;/script&gt;
  1.2987 +</pre>
  1.2988 +      </div>
  1.2989 +    </section>
  1.2990      <section>
  1.2991 -      <h3>Acknowledgements</h3>
  1.2992 -
  1.2993 -      <p>Thanks are expressed by the editor to the following individuals for their feedback on this specification to date (in alphabetical order):
  1.2994 -      <br /><br />
  1.2995 -      Gar Bergstedt, Lars-Erik Bolstad, Cathy Chan, Hari G Kumar, Bob Lund, Giuseppe Pascale, Marcin Simonides, Clarke Stevens, Christian S&ouml;derstr&ouml;m, Mark Vickers, ...</p>
  1.2996 -
  1.2997 -      <p>Thanks are also expressed by the editor to the following organizations and groups for their support in producing this specification to date (in alphabetical order):
  1.2998 -      <br /></br />
  1.2999 -      CableLabs, Opera Software ASA, W3C Device APIs Working Group, W3C Web and TV Interest Group, ...</p>
  1.3000 +      <h3>
  1.3001 +        Acknowledgements
  1.3002 +      </h3>
  1.3003 +      <p>
  1.3004 +        Thanks are expressed by the editor to the following individuals for their feedback on this specification to
  1.3005 +        date (in alphabetical order):<br>
  1.3006 +        <br>
  1.3007 +        Gar Bergstedt, Lars-Erik Bolstad, Cathy Chan, Hari G Kumar, Bob Lund, Giuseppe Pascale, Marcin Simonides,
  1.3008 +        Clarke Stevens, Christian Söderström, Mark Vickers.
  1.3009 +      </p>
  1.3010 +      <p>
  1.3011 +        Thanks are also expressed by the editor to the following organizations and groups for their support in
  1.3012 +        producing this specification to date (in alphabetical order):<br>
  1.3013 +        <br>
  1.3014 +        CableLabs, Opera Software ASA, W3C Device APIs Working Group, W3C Web and TV Interest Group.
  1.3015 +      </p>
  1.3016      </section>
  1.3017 -</body>
  1.3018 +  </body>
  1.3019  </html>