Revert the majority of commit 9e85394e6ede due to the deletion of files. Please always do 'hg pull' followed by 'hg update' before committing your own changes to this repo.
authorRich Tibbett <richt@opera.com>
Mon, 03 Sep 2012 15:35:05 +0200
changeset 21553f4bfeee4fe
parent 214 267ff8e9346c
child 216 5583626294f6
Revert the majority of commit 9e85394e6ede due to the deletion of files. Please always do 'hg pull' followed by 'hg update' before committing your own changes to this repo.
.hgignore
battery/Overview.html
battery/tests/submissions/anssik/TODO.txt
battery/tests/submissions/anssik/battery-charging.html
battery/tests/submissions/anssik/battery-chargingchange.html
battery/tests/submissions/anssik/battery-created.html
battery/tests/submissions/anssik/battery-discharging.html
battery/tests/submissions/anssik/battery-full.html
battery/tests/submissions/anssik/battery_tests.js
battery/tests/submissions/anssik/index.html
battery/tests/submissions/anssik/manifest.txt
discovery-api/FPWD.html
discovery-api/Overview.html
discovery-api/Overview.src.html
gallery/FPWD.html
gallery/Overview.html
humidity/Overview.html
light/FPWD.html
light/Overview.html
light/tests/submissions/marcosc/DeviceLight_tests.js
light/tests/submissions/marcosc/index.html
light/tests/submissions/marcosc/manifest.txt
proximity/FPWD.html
proximity/Overview.html
proximity/tests/submissions/marcos/DeviceProximityEvent_tests.js
proximity/tests/submissions/marcos/UserProximityEvent_tests.js
proximity/tests/submissions/marcos/index.html
proximity/tests/submissions/marcos/manifest.txt
temperature/Overview.html
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/.hgignore	Mon Sep 03 15:35:05 2012 +0200
     1.3 @@ -0,0 +1,4 @@
     1.4 +# use glob syntax.
     1.5 +syntax: glob
     1.6 +
     1.7 +.DS_Store
     2.1 --- a/battery/Overview.html	Sun Sep 02 11:11:35 2012 +0200
     2.2 +++ b/battery/Overview.html	Mon Sep 03 15:35:05 2012 +0200
     2.3 @@ -6,11 +6,11 @@
     2.4      <script src='http://www.w3.org/Tools/respec/respec-w3c-common' class='remove'></script>
     2.5      <script class="remove">
     2.6        var respecConfig = {
     2.7 -          specStatus:           "CR",
     2.8 +          specStatus:           "ED",
     2.9            shortName:            "battery-status",
    2.10 -          publishDate:          "2012-05-08",
    2.11 -          previousPublishDate:  "2011-11-29",
    2.12 -          previousMaturity:     "LC",
    2.13 +          //publishDate:          "2012-05-08",
    2.14 +          previousPublishDate:  "2012-05-08",
    2.15 +          previousMaturity:     "CR",
    2.16            edDraftURI:           "http://dvcs.w3.org/hg/dap/raw-file/tip/battery/Overview.html",
    2.17            // lcEnd:                "2011-12-20",
    2.18            crEnd:                "2012-07-01",
    2.19 @@ -189,9 +189,9 @@
    2.20      <section>
    2.21        <h2>Terminology</h2>
    2.22        <p>
    2.23 -        The <code><a href="http://dev.w3.org/html5/spec/webappapis.html#function">
    2.24 -        Function</a></code> interface represents a function in the scripting
    2.25 -        language being used as defined in [[!HTML5]].
    2.26 +        The <code><a href="http://dev.w3.org/html5/spec/webappapis.html#eventhandler">
    2.27 +        EventHandler</a></code> interface represents a callback used for event
    2.28 +        handlers as defined in [[!HTML5]].
    2.29        </p>
    2.30        <p>
    2.31          The concepts <dfn><a href="http://dev.w3.org/html5/spec/webappapis.html#queue-a-task">
    2.32 @@ -255,22 +255,22 @@
    2.33            Represents the current battery level scaled from 0 to 1.0.
    2.34          </dd>
    2.35          <dt class="no-docs">
    2.36 -          [TreatNonCallableAsNull] attribute Function? onchargingchange
    2.37 +          attribute EventHandler onchargingchange
    2.38          </dt>
    2.39          <dd>
    2.40          </dd>
    2.41          <dt class="no-docs">
    2.42 -          [TreatNonCallableAsNull] attribute Function? onchargingtimechange
    2.43 +          attribute EventHandler onchargingtimechange
    2.44          </dt>
    2.45          <dd>
    2.46          </dd>
    2.47          <dt class="no-docs">
    2.48 -          [TreatNonCallableAsNull] attribute Function? ondischargingtimechange
    2.49 +          attribute EventHandler ondischargingtimechange
    2.50          </dt>
    2.51          <dd>
    2.52          </dd>
    2.53          <dt class="no-docs">
    2.54 -          [TreatNonCallableAsNull] attribute Function? onlevelchange
    2.55 +          attribute EventHandler onlevelchange
    2.56          </dt>
    2.57          <dd>
    2.58          </dd>
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/battery/tests/submissions/anssik/TODO.txt	Mon Sep 03 15:35:05 2012 +0200
     3.3 @@ -0,0 +1,5 @@
     3.4 +---+ TODO
     3.5 +  
     3.6 +   * proper {level | chargingtime | dischargingtime}change tests
     3.7 +   * async tests for *change when plugged in
     3.8 +   * validate tests on a real device and tweak timeouts for async tests
     3.9 \ No newline at end of file
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/battery/tests/submissions/anssik/battery-charging.html	Mon Sep 03 15:35:05 2012 +0200
     4.3 @@ -0,0 +1,45 @@
     4.4 +<!DOCTYPE html>
     4.5 +<html>
     4.6 +  <head>
     4.7 +  <title>Battery Status API Test Suite</title>
     4.8 +  <script src="http://www.w3c-test.org/resources/testharness.js"></script>
     4.9 +  <link rel='stylesheet' href='http://w3c-test.org/resources/testharness.css' media='all'/>
    4.10 +  </head>
    4.11 +  <body>
    4.12 +    <h1>Description</h1>
    4.13 +    <p>
    4.14 +      The battery is charging.
    4.15 +    </p>
    4.16 +    <h2>Preconditions</h2>
    4.17 +    <ol>
    4.18 +      <li>
    4.19 +        The device is plugged in to the charger before this test case is run.
    4.20 +      </li>
    4.21 +      <li>
    4.22 +        The battery must neither be empty or full, nor reach empty or full capacity during the test.
    4.23 +      </li>
    4.24 +    </ol>
    4.25 +    <div id="log"></div>
    4.26 +    <script>
    4.27 +    (function() {
    4.28 +
    4.29 +      test(function() {
    4.30 +        assert_true(navigator.battery.charging);
    4.31 +      }, 'The charging attribute must be set to true if the battery is charging.');
    4.32 +      
    4.33 +      test(function() {
    4.34 +        assert_true(navigator.battery.chargingTime < Infinity);
    4.35 +      }, 'The chargingTime attribute must be set to the value positive Infinity if the battery is discharging');
    4.36 +      
    4.37 +      test(function() {
    4.38 +        assert_true(navigator.battery.dischargingTime === Infinity);
    4.39 +      }, 'The dischargingTime attribute must be set to the value positive Infinity, if the battery is charging.');
    4.40 +      
    4.41 +      test(function() {
    4.42 +        assert_true(0 < navigator.battery.level && navigator.battery.level < 1.0);
    4.43 +      }, 'The level attribute must be set to the current battery level scaled from 0 to 1.0.');
    4.44 +      
    4.45 +    })();
    4.46 +    </script>
    4.47 +  </body>
    4.48 +</html>
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/battery/tests/submissions/anssik/battery-chargingchange.html	Mon Sep 03 15:35:05 2012 +0200
     5.3 @@ -0,0 +1,57 @@
     5.4 +<!DOCTYPE html>
     5.5 +<html>
     5.6 +  <head>
     5.7 +  <title>Battery Status API Test Suite</title>
     5.8 +  <script src="http://www.w3c-test.org/resources/testharness.js"></script>
     5.9 +  <link rel='stylesheet' href='http://w3c-test.org/resources/testharness.css' media='all'/>
    5.10 +  </head>
    5.11 +  <body>
    5.12 +    <h1>Description</h1>
    5.13 +    <p>
    5.14 +       The battery charging state is updated.
    5.15 +    </p>
    5.16 +    <h2>Preconditions</h2>
    5.17 +    <ol>
    5.18 +      <li>
    5.19 +        The device is unplugged from the charger before this test case is run.
    5.20 +      </li>
    5.21 +      <li>
    5.22 +        The battery must not be full or reach full capacity during the time the test is run.
    5.23 +      </li>
    5.24 +    </ol>
    5.25 +    <div id="log"></div>
    5.26 +    <script>
    5.27 +    (function() {
    5.28 +
    5.29 +      // this is the pattern used for testing event handlers
    5.30 +      
    5.31 +      /*
    5.32 +      var onclick_test = async_test('onclick on body');
    5.33 +      document.querySelector('body').onclick = onclick_test.step_func(function (e) {
    5.34 +        // assert_xxxx();
    5.35 +        onclick_test.done();
    5.36 +      });
    5.37 +      
    5.38 +      alert('click on body!');
    5.39 +      */
    5.40 +
    5.41 +      // the tests below must be validated on a real implementation, to set proper timeouts etc.
    5.42 +      
    5.43 +      var onchargingchange_test = async_test('When the battery charging state is updated, must fire a chargingchange event.');
    5.44 +      navigator.battery.onchargingchange = onchargingchange_test.step_func(function (e) {
    5.45 +        assert_true(navigator.battery.charging, 'The charging attribute must be set to true, if the battery is charging.')
    5.46 +        onchargingchange_test.done();
    5.47 +      });
    5.48 +      
    5.49 +      var onchargingtimechange_test = async_test('When the battery charging time is updated, must fire a chargingtimechange event.');
    5.50 +      navigator.battery.onchargingtimechange = onchargingtimechange_test.step_func(function (e) {
    5.51 +        assert_false(navigator.battery.chargingTime !== Infinity);
    5.52 +        onchargingchange_test.done();
    5.53 +      });
    5.54 +      
    5.55 +      alert('Plug in the charger, and click OK.');
    5.56 +
    5.57 +      })();
    5.58 +    </script>
    5.59 +  </body>
    5.60 +</html>
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/battery/tests/submissions/anssik/battery-created.html	Mon Sep 03 15:35:05 2012 +0200
     6.3 @@ -0,0 +1,43 @@
     6.4 +<!DOCTYPE html>
     6.5 +<html>
     6.6 +  <head>
     6.7 +  <title>Battery Status API Test Suite</title>
     6.8 +  <script src="http://www.w3c-test.org/resources/testharness.js"></script>
     6.9 +  <link rel='stylesheet' href='http://w3c-test.org/resources/testharness.css' media='all'/>
    6.10 +  </head>
    6.11 +  <body>
    6.12 +    <h1>Description</h1>
    6.13 +    <p>
    6.14 +      <strong>
    6.15 +        This test is only useful on devices that expose the BatteryManager interface,
    6.16 +        but lack a backend implementation.
    6.17 +      </strong>
    6.18 +    </p>
    6.19 +    <h2>Preconditions</h2>
    6.20 +    <ol>
    6.21 +      <li>
    6.22 +        The implementation is unable to report the battery's charging state,
    6.23 +        charging time, level or remaining time respectively.
    6.24 +      </li>
    6.25 +      <li>
    6.26 +        The device is unplugged from the charger before this test case is run.
    6.27 +      </li>
    6.28 +    </ol>
    6.29 +    <div id="log"></div>
    6.30 +    <script>
    6.31 +    (function() {
    6.32 +      test(function() {
    6.33 +        var b = navigator.battery;
    6.34 +        assert_true(b.charging === true, 'charging must be set to true');
    6.35 +        assert_true(b.chargingTime === 0, 'chargingTime must be set to 0');
    6.36 +        assert_true(b.level === 1.0, 'level must be set to 1.0');
    6.37 +        assert_true(b.dischargingTime === Infinity, 'dischargingTime must be set to Infinity');
    6.38 +
    6.39 +      }, 'When a BatteryManager object is created, charging must be set to true, ' +
    6.40 +      'chargingTime to 0, level to 1.0 and dischargingTime to the value positive ' +
    6.41 +      'Infinity, if the implementation is unable to report the battery\'s charging ' +
    6.42 +      'state, charging time, level or remaining time respectively.');
    6.43 +      })();
    6.44 +    </script>
    6.45 +  </body>
    6.46 +</html>
     7.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.2 +++ b/battery/tests/submissions/anssik/battery-discharging.html	Mon Sep 03 15:35:05 2012 +0200
     7.3 @@ -0,0 +1,46 @@
     7.4 +<!DOCTYPE html>
     7.5 +<html>
     7.6 +  <head>
     7.7 +  <title>Battery Status API Test Suite</title>
     7.8 +  <script src="http://www.w3c-test.org/resources/testharness.js"></script>
     7.9 +  <link rel='stylesheet' href='http://w3c-test.org/resources/testharness.css' media='all'/>
    7.10 +  </head>
    7.11 +  <body>
    7.12 +    <h1>Description</h1>
    7.13 +    <p>
    7.14 +      The battery is discharging.
    7.15 +    </p>
    7.16 +    <h2>Preconditions</h2>
    7.17 +    <ol>
    7.18 +      <li>
    7.19 +        The device is unplugged from the charger before this test case is run.
    7.20 +      </li>
    7.21 +      <li>
    7.22 +        The battery must neither be empty or full, nor reach empty or full capacity during the test.
    7.23 +      </li>
    7.24 +    </ol>
    7.25 +    <div id="log"></div>
    7.26 +    <script>
    7.27 +    (function() {
    7.28 +
    7.29 +      test(function() {
    7.30 +        assert_false(navigator.battery.charging);
    7.31 +      }, 'The charging attribute must be set to false if the battery is discharging.');
    7.32 +      
    7.33 +      test(function() {
    7.34 +        assert_true(navigator.battery.chargingTime === Infinity);
    7.35 +      }, 'The chargingTime attribute must be set to the value positive Infinity if the battery is discharging');
    7.36 +      
    7.37 +      test(function() {
    7.38 +        assert_true(navigator.battery.dischargingTime < Infinity);
    7.39 +      }, 'The dischargingTime attribute must be set to the time remaining in ' +
    7.40 +      'seconds until the system\'s battery is completely discharged.');
    7.41 +      
    7.42 +      test(function() {
    7.43 +        assert_true(0 <= navigator.battery.level && navigator.battery.level <= 1.0);
    7.44 +      }, 'The level attribute must be set to the current battery level scaled from 0 to 1.0');
    7.45 +      
    7.46 +    })();
    7.47 +    </script>
    7.48 +  </body>
    7.49 +</html>
     8.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.2 +++ b/battery/tests/submissions/anssik/battery-full.html	Mon Sep 03 15:35:05 2012 +0200
     8.3 @@ -0,0 +1,45 @@
     8.4 +<!DOCTYPE html>
     8.5 +<html>
     8.6 +  <head>
     8.7 +  <title>Battery Status API Test Suite</title>
     8.8 +  <script src="http://www.w3c-test.org/resources/testharness.js"></script>
     8.9 +  <link rel='stylesheet' href='http://w3c-test.org/resources/testharness.css' media='all'/>
    8.10 +  </head>
    8.11 +  <body>
    8.12 +    <h1>Description</h1>
    8.13 +    <p>
    8.14 +      The battery is full.
    8.15 +    </p>
    8.16 +    <h2>Preconditions</h2>
    8.17 +    <ol>
    8.18 +      <li>
    8.19 +        The device is plugged in to the charger before this test case is run.
    8.20 +      </li>
    8.21 +      <li>
    8.22 +        The battery is full.
    8.23 +      </li>
    8.24 +    </ol>
    8.25 +    <div id="log"></div>
    8.26 +    <script>
    8.27 +    (function() {
    8.28 +
    8.29 +      test(function() {
    8.30 +        assert_true(navigator.battery.charging);
    8.31 +      }, 'The charging attribute must be set to true if the battery is charging ("or otherwise" condition).');
    8.32 +      
    8.33 +      test(function() {
    8.34 +        assert_true(navigator.battery.chargingTime === 0);
    8.35 +      }, 'The chargingTime attribute must be set to 0, if the battery is full.');
    8.36 +      
    8.37 +      test(function() {
    8.38 +        assert_true(navigator.battery.dischargingTime === Infinity);
    8.39 +      }, 'The dischargingTime attribute must be set to the value positive Infinity if the battery is charging ("or otherwise" condition).');
    8.40 +      
    8.41 +      test(function() {
    8.42 +        assert_true(navigator.battery.level === 1.0);
    8.43 +      }, 'The level attribute must be set to the current battery level scaled from 0 to 1.0.');
    8.44 +      
    8.45 +    })();
    8.46 +    </script>
    8.47 +  </body>
    8.48 +</html>
     9.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.2 +++ b/battery/tests/submissions/anssik/battery_tests.js	Mon Sep 03 15:35:05 2012 +0200
     9.3 @@ -0,0 +1,393 @@
     9.4 +/**
     9.5 +* W3C 3-clause BSD License
     9.6 +* Redistribution and use in source and binary forms, with or without
     9.7 +* modification, are permitted provided that the following conditions are
     9.8 +* met:
     9.9 +* o Redistributions of works must retain the original copyright notice,
    9.10 +*     this list of conditions and the following disclaimer.
    9.11 +*
    9.12 +* o Redistributions in binary form must reproduce the original copyright
    9.13 +*     notice, this list of conditions and the following disclaimer in the
    9.14 +*     documentation and/or other materials provided with the distribution.
    9.15 +*
    9.16 +* o Neither the name of the W3C nor the names of its contributors may be
    9.17 +*     used to endorse or promote products derived from this work without
    9.18 +*     specific prior written permission.
    9.19 +*
    9.20 +* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
    9.21 +* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
    9.22 +* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
    9.23 +* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
    9.24 +* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
    9.25 +* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
    9.26 +* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
    9.27 +* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
    9.28 +* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
    9.29 +* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
    9.30 +* POSSIBILITY OF SUCH DAMAGE.
    9.31 +**/
    9.32 +
    9.33 +(function() {
    9.34 +  
    9.35 +  /**
    9.36 +  *
    9.37 +  * Navigator implements NavigatorBattery;
    9.38 +  *
    9.39 +  * [NoInterfaceObject]
    9.40 +  * interface NavigatorBattery {
    9.41 +  *    readonly attribute BatteryManager battery;
    9.42 +  * };
    9.43 +  *
    9.44 +  */
    9.45 +  
    9.46 +  test(function() {
    9.47 +    assert_idl_attribute(navigator, 'battery', 'navigator must have battery attribute');
    9.48 +  }, 'battery is present on navigator');
    9.49 +    
    9.50 +  test(function() {
    9.51 +    assert_readonly(navigator, 'battery', 'battery must be readonly')
    9.52 +  }, 'battery is readonly');
    9.53 +  
    9.54 +  /**
    9.55 +  *
    9.56 +  * [NoInterfaceObject]
    9.57 +  * interface BatteryManager : EventTarget {
    9.58 +  *     readonly attribute boolean      charging;
    9.59 +  *     readonly attribute double       chargingTime;
    9.60 +  *     readonly attribute double       dischargingTime;
    9.61 +  *     readonly attribute double       level;
    9.62 +  *              attribute EventHandler onchargingchange;
    9.63 +  *              attribute EventHandler onchargingtimechange;
    9.64 +  *              attribute EventHandler ondischargingtimechange;
    9.65 +  *              attribute EventHandler onlevelchange;
    9.66 +  * };
    9.67 +  *
    9.68 +  */
    9.69 +
    9.70 +  // interface BatteryManager : EventTarget {
    9.71 +  
    9.72 +  test(function() {
    9.73 +      assert_true(navigator.battery instanceof EventTarget);
    9.74 +  }, 'battery inherits from EventTarget');
    9.75 +  
    9.76 +  // readonly attribute boolean charging;
    9.77 +  
    9.78 +  test(function() {
    9.79 +    assert_idl_attribute(navigator.battery, 'charging', 'battery must have charging attribute');
    9.80 +  }, 'charging attribute exists');
    9.81 +  
    9.82 +  test(function() {
    9.83 +    assert_readonly(navigator.battery, 'charging', 'charging must be readonly')
    9.84 +  }, 'charging attribute is readonly');
    9.85 +
    9.86 +  // readonly attribute double chargingTime;
    9.87 +
    9.88 +  test(function() {
    9.89 +    assert_idl_attribute(navigator.battery, 'chargingTime', 'battery must have chargingTime attribute');
    9.90 +  }, 'chargingTime attribute exists');
    9.91 +
    9.92 +  test(function() {
    9.93 +    assert_readonly(navigator.battery, 'chargingTime', 'chargingTime must be readonly')
    9.94 +  }, 'chargingTime attribute is readonly');
    9.95 +
    9.96 +  // readonly attribute double dischargingTime;
    9.97 +
    9.98 +  test(function() {
    9.99 +    assert_idl_attribute(navigator.battery, 'dischargingTime', 'battery must have dischargingTime attribute');
   9.100 +  }, 'dischargingTime attribute exists');
   9.101 +
   9.102 +  test(function() {
   9.103 +    assert_readonly(navigator.battery, 'dischargingTime', 'dischargingTime must be readonly')
   9.104 +  }, 'dischargingTime attribute is readonly');
   9.105 +  
   9.106 +  // readonly attribute double level;
   9.107 +  
   9.108 +  test(function() {
   9.109 +    assert_idl_attribute(navigator.battery, 'level', 'battery must have level attribute');
   9.110 +  }, 'level attribute exists');
   9.111 +
   9.112 +  test(function() {
   9.113 +    assert_readonly(navigator.battery, 'level', 'level must be readonly')
   9.114 +  }, 'level attribute is readonly');
   9.115 +  
   9.116 +  // attribute EventHandler onchargingchange;
   9.117 +  
   9.118 +  test(function() {
   9.119 +    assert_idl_attribute(navigator.battery, 'onchargingchange', 'battery must have onchargingchange attribute');
   9.120 +  }, 'onchargingchange attribute exists');
   9.121 +  
   9.122 +  test(function() {
   9.123 +    assert_equals(navigator.battery.onchargingchange, null, 'onchargingchange must be null')
   9.124 +  }, 'onchargingchange is null');
   9.125 +  
   9.126 +  test(function() {
   9.127 +      var desc = 'onchargingchange did not accept callable object',
   9.128 +          func = function() {},
   9.129 +          desc = 'Expected to find onchargingchange attribute on battery object';
   9.130 +      assert_idl_attribute(navigator.battery, 'onchargingchange', desc);
   9.131 +      window.onchargingchange = func;
   9.132 +      assert_equals(window.onchargingchange, func, desc);
   9.133 +  }, 'onchargingchange is set to function');
   9.134 +  
   9.135 +  test(function() {
   9.136 +      var desc = 'onchargingchange did not treat noncallable as null';
   9.137 +      navigator.battery.onchargingchange = function() {};
   9.138 +      navigator.battery.onchargingchange = {};
   9.139 +      assert_equals(navigator.battery.onchargingchange, null, desc);
   9.140 +  }, 'onchargingchange: treat object as null');
   9.141 +  
   9.142 +  test(function() {
   9.143 +      var desc = 'onchargingchange did not treat noncallable as null';
   9.144 +      navigator.battery.onchargingchange = function() {};
   9.145 +      navigator.battery.onchargingchange = {
   9.146 +          call: 'test'
   9.147 +      };
   9.148 +      assert_equals(navigator.battery.onchargingchange, null, desc);
   9.149 +  }, 'onchargingchange: treat object with non-callable call property as null');
   9.150 +  
   9.151 +  test(function() {
   9.152 +      var desc = 'onchargingchange did not treat noncallable (string) as null';
   9.153 +      navigator.battery.onchargingchange = function() {};
   9.154 +      navigator.battery.onchargingchange = 'string';
   9.155 +      assert_equals(navigator.battery.onchargingchange, null, desc);
   9.156 +  }, 'onchargingchange: treat string as null');
   9.157 +
   9.158 +  test(function() {
   9.159 +      var desc = 'onchargingchange did not treat noncallable (number) as null';
   9.160 +      navigator.battery.onchargingchange = function() {};
   9.161 +      navigator.battery.onchargingchange = 123;
   9.162 +      assert_equals(navigator.battery.onchargingchange, null, desc);
   9.163 +  }, 'onchargingchange: treat number as null');
   9.164 +
   9.165 +  test(function() {
   9.166 +      var desc = 'onchargingchange did not treat noncallable (undefined) as null';
   9.167 +      navigator.battery.onchargingchange = function() {};
   9.168 +      navigator.battery.onchargingchange = undefined;
   9.169 +      assert_equals(navigator.battery.onchargingchange, null, desc);
   9.170 +  }, 'onchargingchange: treat undefined as null');
   9.171 +
   9.172 +  test(function() {
   9.173 +      var desc = 'onchargingchange did not treat noncallable (array) as null';
   9.174 +      navigator.battery.onchargingchange = function() {};
   9.175 +      navigator.battery.onchargingchange = [];
   9.176 +      assert_equals(navigator.battery.onchargingchange, null, desc);
   9.177 +  }, 'onchargingchange: treat array as null');
   9.178 +
   9.179 +  test(function() {
   9.180 +      var desc = 'onchargingchange did not treat noncallable host object as null';
   9.181 +      navigator.battery.onchargingchange = function() {};
   9.182 +      navigator.battery.onchargingchange = Node;
   9.183 +      assert_equals(navigator.battery.onchargingchange, null, desc);
   9.184 +  }, 'onchargingchange: treat non-callable host object as null');
   9.185 +  
   9.186 +  // attribute EventHandler onchargingtimechange;
   9.187 +  
   9.188 +  test(function() {
   9.189 +    assert_idl_attribute(navigator.battery, 'onchargingtimechange', 'battery must have onchargingtimechange attribute');
   9.190 +  }, 'onchargingtimechange attribute exists');
   9.191 +  
   9.192 +  test(function() {
   9.193 +    assert_equals(navigator.battery.onchargingtimechange, null, 'onchargingtimechange must be null')
   9.194 +  }, 'onchargingtimechange is null');
   9.195 +
   9.196 +  test(function() {
   9.197 +      var desc = 'onchargingtimechange did not accept callable object',
   9.198 +          func = function() {},
   9.199 +          desc = 'Expected to find onchargingtimechange attribute on battery object';
   9.200 +      assert_idl_attribute(navigator.battery, 'onchargingtimechange', desc);
   9.201 +      window.onchargingtimechange = func;
   9.202 +      assert_equals(window.onchargingtimechange, func, desc);
   9.203 +  }, 'onchargingtimechange is set to function');
   9.204 +
   9.205 +  test(function() {
   9.206 +      var desc = 'onchargingtimechange did not treat noncallable as null';
   9.207 +      navigator.battery.onchargingtimechange = function() {};
   9.208 +      navigator.battery.onchargingtimechange = {};
   9.209 +      assert_equals(navigator.battery.onchargingtimechange, null, desc);
   9.210 +  }, 'onchargingtimechange: treat object as null');
   9.211 +
   9.212 +  test(function() {
   9.213 +      var desc = 'onchargingtimechange did not treat noncallable as null';
   9.214 +      navigator.battery.onchargingtimechange = function() {};
   9.215 +      navigator.battery.onchargingtimechange = {
   9.216 +          call: 'test'
   9.217 +      };
   9.218 +      assert_equals(navigator.battery.onchargingtimechange, null, desc);
   9.219 +  }, 'onchargingtimechange: treat object with non-callable call property as null');
   9.220 +
   9.221 +  test(function() {
   9.222 +      var desc = 'onchargingtimechange did not treat noncallable (string) as null';
   9.223 +      navigator.battery.onchargingtimechange = function() {};
   9.224 +      navigator.battery.onchargingtimechange = 'string';
   9.225 +      assert_equals(navigator.battery.onchargingtimechange, null, desc);
   9.226 +  }, 'onchargingtimechange: treat string as null');
   9.227 +
   9.228 +  test(function() {
   9.229 +      var desc = 'onchargingtimechange did not treat noncallable (number) as null';
   9.230 +      navigator.battery.onchargingtimechange = function() {};
   9.231 +      navigator.battery.onchargingtimechange = 123;
   9.232 +      assert_equals(navigator.battery.onchargingtimechange, null, desc);
   9.233 +  }, 'onchargingtimechange: treat number as null');
   9.234 +
   9.235 +  test(function() {
   9.236 +      var desc = 'onchargingtimechange did not treat noncallable (undefined) as null';
   9.237 +      navigator.battery.onchargingtimechange = function() {};
   9.238 +      navigator.battery.onchargingtimechange = undefined;
   9.239 +      assert_equals(navigator.battery.onchargingtimechange, null, desc);
   9.240 +  }, 'onchargingtimechange: treat undefined as null');
   9.241 +
   9.242 +  test(function() {
   9.243 +      var desc = 'onchargingtimechange did not treat noncallable (array) as null';
   9.244 +      navigator.battery.onchargingtimechange = function() {};
   9.245 +      navigator.battery.onchargingtimechange = [];
   9.246 +      assert_equals(navigator.battery.onchargingtimechange, null, desc);
   9.247 +  }, 'onchargingtimechange: treat array as null');
   9.248 +
   9.249 +  test(function() {
   9.250 +      var desc = 'onchargingtimechange did not treat noncallable host object as null';
   9.251 +      navigator.battery.onchargingtimechange = function() {};
   9.252 +      navigator.battery.onchargingtimechange = Node;
   9.253 +      assert_equals(navigator.battery.onchargingtimechange, null, desc);
   9.254 +  }, 'onchargingtimechange: treat non-callable host object as null');
   9.255 +    
   9.256 +  // attribute EventHandler ondischargingtimechange;
   9.257 +  
   9.258 +  test(function() {
   9.259 +    assert_idl_attribute(navigator.battery, 'ondischargingtimechange', 'battery must have ondischargingtimechange attribute');
   9.260 +  }, 'ondischargingtimechange attribute exists');
   9.261 +
   9.262 +  test(function() {
   9.263 +    assert_equals(navigator.battery.ondischargingtimechange, null, 'ondischargingtimechange must be null')
   9.264 +  }, 'ondischargingtimechange is null');
   9.265 +  
   9.266 +  test(function() {
   9.267 +      var desc = 'ondischargingtimechange did not accept callable object',
   9.268 +          func = function() {},
   9.269 +          desc = 'Expected to find ondischargingtimechange attribute on battery object';
   9.270 +      assert_idl_attribute(navigator.battery, 'ondischargingtimechange', desc);
   9.271 +      window.ondischargingtimechange = func;
   9.272 +      assert_equals(window.ondischargingtimechange, func, desc);
   9.273 +  }, 'ondischargingtimechange is set to function');
   9.274 +
   9.275 +  test(function() {
   9.276 +      var desc = 'ondischargingtimechange did not treat noncallable as null';
   9.277 +      navigator.battery.ondischargingtimechange = function() {};
   9.278 +      navigator.battery.ondischargingtimechange = {};
   9.279 +      assert_equals(navigator.battery.ondischargingtimechange, null, desc);
   9.280 +  }, 'ondischargingtimechange: treat object as null');
   9.281 +
   9.282 +  test(function() {
   9.283 +      var desc = 'ondischargingtimechange did not treat noncallable as null';
   9.284 +      navigator.battery.ondischargingtimechange = function() {};
   9.285 +      navigator.battery.ondischargingtimechange = {
   9.286 +          call: 'test'
   9.287 +      };
   9.288 +      assert_equals(navigator.battery.ondischargingtimechange, null, desc);
   9.289 +  }, 'ondischargingtimechange: treat object with non-callable call property as null');
   9.290 +
   9.291 +  test(function() {
   9.292 +      var desc = 'ondischargingtimechange did not treat noncallable (string) as null';
   9.293 +      navigator.battery.ondischargingtimechange = function() {};
   9.294 +      navigator.battery.ondischargingtimechange = 'string';
   9.295 +      assert_equals(navigator.battery.ondischargingtimechange, null, desc);
   9.296 +  }, 'ondischargingtimechange: treat string as null');
   9.297 +
   9.298 +  test(function() {
   9.299 +      var desc = 'ondischargingtimechange did not treat noncallable (number) as null';
   9.300 +      navigator.battery.ondischargingtimechange = function() {};
   9.301 +      navigator.battery.ondischargingtimechange = 123;
   9.302 +      assert_equals(navigator.battery.ondischargingtimechange, null, desc);
   9.303 +  }, 'ondischargingtimechange: treat number as null');
   9.304 +
   9.305 +  test(function() {
   9.306 +      var desc = 'ondischargingtimechange did not treat noncallable (undefined) as null';
   9.307 +      navigator.battery.ondischargingtimechange = function() {};
   9.308 +      navigator.battery.ondischargingtimechange = undefined;
   9.309 +      assert_equals(navigator.battery.ondischargingtimechange, null, desc);
   9.310 +  }, 'ondischargingtimechange: treat undefined as null');
   9.311 +
   9.312 +  test(function() {
   9.313 +      var desc = 'ondischargingtimechange did not treat noncallable (array) as null';
   9.314 +      navigator.battery.ondischargingtimechange = function() {};
   9.315 +      navigator.battery.ondischargingtimechange = [];
   9.316 +      assert_equals(navigator.battery.ondischargingtimechange, null, desc);
   9.317 +  }, 'ondischargingtimechange: treat array as null');
   9.318 +
   9.319 +  test(function() {
   9.320 +      var desc = 'ondischargingtimechange did not treat noncallable host object as null';
   9.321 +      navigator.battery.ondischargingtimechange = function() {};
   9.322 +      navigator.battery.ondischargingtimechange = Node;
   9.323 +      assert_equals(navigator.battery.ondischargingtimechange, null, desc);
   9.324 +  }, 'ondischargingtimechange: treat non-callable host object as null');
   9.325 +
   9.326 +  // attribute EventHandler onlevelchange;
   9.327 +
   9.328 +  test(function() {
   9.329 +    assert_idl_attribute(navigator.battery, 'onlevelchange', 'battery must have onlevelchange attribute');
   9.330 +  }, 'onlevelchange attribute exists');
   9.331 +  
   9.332 +  test(function() {
   9.333 +    assert_equals(navigator.battery.onlevelchange, null, 'onlevelchange must be null')
   9.334 +  }, 'onlevelchange is null');
   9.335 +  
   9.336 +  test(function() {
   9.337 +      var desc = 'onlevelchange did not accept callable object',
   9.338 +          func = function() {},
   9.339 +          desc = 'Expected to find onlevelchange attribute on battery object';
   9.340 +      assert_idl_attribute(navigator.battery, 'onlevelchange', desc);
   9.341 +      window.onlevelchange = func;
   9.342 +      assert_equals(window.onlevelchange, func, desc);
   9.343 +  }, 'onlevelchange is set to function');
   9.344 +
   9.345 +  test(function() {
   9.346 +      var desc = 'onlevelchange did not treat noncallable as null';
   9.347 +      navigator.battery.onlevelchange = function() {};
   9.348 +      navigator.battery.onlevelchange = {};
   9.349 +      assert_equals(navigator.battery.onlevelchange, null, desc);
   9.350 +  }, 'onlevelchange: treat object as null');
   9.351 +
   9.352 +  test(function() {
   9.353 +      var desc = 'onlevelchange did not treat noncallable as null';
   9.354 +      navigator.battery.onlevelchange = function() {};
   9.355 +      navigator.battery.onlevelchange = {
   9.356 +          call: 'test'
   9.357 +      };
   9.358 +      assert_equals(navigator.battery.onlevelchange, null, desc);
   9.359 +  }, 'onlevelchange: treat object with non-callable call property as null');
   9.360 +
   9.361 +  test(function() {
   9.362 +      var desc = 'onlevelchange did not treat noncallable (string) as null';
   9.363 +      navigator.battery.onlevelchange = function() {};
   9.364 +      navigator.battery.onlevelchange = 'string';
   9.365 +      assert_equals(navigator.battery.onlevelchange, null, desc);
   9.366 +  }, 'onlevelchange: treat string as null');
   9.367 +
   9.368 +  test(function() {
   9.369 +      var desc = 'onlevelchange did not treat noncallable (number) as null';
   9.370 +      navigator.battery.onlevelchange = function() {};
   9.371 +      navigator.battery.onlevelchange = 123;
   9.372 +      assert_equals(navigator.battery.onlevelchange, null, desc);
   9.373 +  }, 'onlevelchange: treat number as null');
   9.374 +
   9.375 +  test(function() {
   9.376 +      var desc = 'onlevelchange did not treat noncallable (undefined) as null';
   9.377 +      navigator.battery.onlevelchange = function() {};
   9.378 +      navigator.battery.onlevelchange = undefined;
   9.379 +      assert_equals(navigator.battery.onlevelchange, null, desc);
   9.380 +  }, 'onlevelchange: treat undefined as null');
   9.381 +
   9.382 +  test(function() {
   9.383 +      var desc = 'onlevelchange did not treat noncallable (array) as null';
   9.384 +      navigator.battery.onlevelchange = function() {};
   9.385 +      navigator.battery.onlevelchange = [];
   9.386 +      assert_equals(navigator.battery.onlevelchange, null, desc);
   9.387 +  }, 'onlevelchange: treat array as null');
   9.388 +
   9.389 +  test(function() {
   9.390 +      var desc = 'onlevelchange did not treat noncallable host object as null';
   9.391 +      navigator.battery.onlevelchange = function() {};
   9.392 +      navigator.battery.onlevelchange = Node;
   9.393 +      assert_equals(navigator.battery.onlevelchange, null, desc);
   9.394 +  }, 'onlevelchange: treat non-callable host object as null');
   9.395 +  
   9.396 +})();
   9.397 \ No newline at end of file
    10.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    10.2 +++ b/battery/tests/submissions/anssik/index.html	Mon Sep 03 15:35:05 2012 +0200
    10.3 @@ -0,0 +1,23 @@
    10.4 +<!DOCTYPE html>
    10.5 +<html>
    10.6 +<head>
    10.7 +<title>Battery Status API Test Suite</title>
    10.8 +<script src="http://www.w3c-test.org/resources/testharness.js"></script>
    10.9 +<script src="battery_tests.js"></script>
   10.10 +</head>
   10.11 +<body>
   10.12 +<h1>Test Suite for Battery Status API (Work in Progress)</h1>
   10.13 +<div id="log"></div>
   10.14 +<p>
   10.15 +  <small>
   10.16 +    Distributed under both the
   10.17 +    <a href="http://www.w3.org/Consortium/Legal/2008/04-testsuite-license">
   10.18 +    W3C Test Suite License</a> and the
   10.19 +    <a href="http://www.w3.org/Consortium/Legal/2008/03-bsd-license">
   10.20 +    W3C 3-clause BSD License</a>. To contribute to a W3C Test Suite, see the
   10.21 +    <a href="http://www.w3.org/2004/10/27-testcases">policies and contribution
   10.22 +    forms</a>.
   10.23 +  </small>
   10.24 +</p>
   10.25 +</body>
   10.26 +</html>
   10.27 \ No newline at end of file
    11.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    11.2 +++ b/battery/tests/submissions/anssik/manifest.txt	Mon Sep 03 15:35:05 2012 +0200
    11.3 @@ -0,0 +1,6 @@
    11.4 +index.html		Battery Status API Test Suite					
    11.5 +battery-charging.html		Battery Status API Test Suite					
    11.6 +battery-chargingchange.html		Battery Status API Test Suite					
    11.7 +battery-created.html		Battery Status API Test Suite					
    11.8 +battery-discharging.html		Battery Status API Test Suite					
    11.9 +battery-full.html		Battery Status API Test Suite					
    12.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    12.2 +++ b/discovery-api/FPWD.html	Mon Sep 03 15:35:05 2012 +0200
    12.3 @@ -0,0 +1,1797 @@
    12.4 +<!DOCTYPE html>
    12.5 +<html lang="en" dir="ltr">
    12.6 +<head>
    12.7 +    <title>Networked Service Discovery and Messaging</title>
    12.8 +    <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
    12.9 +    
   12.10 +
   12.11 +    
   12.12 +    <style type="text/css">
   12.13 +      /* Custom CSS optimizations (Richard Tibbett) */
   12.14 +
   12.15 +      /* Add better spacing to sections */
   12.16 +      section, .section { margin-bottom: 2em; }
   12.17 +
   12.18 +      /* Reduce note & issue render size */
   12.19 +      .note, .issue { font-size:0.8em; }
   12.20 +
   12.21 +      /* Add addition spacing to <ol> and <ul> for rule definition */
   12.22 +      ol.rule li, ul.rule li { padding:0.6em; }
   12.23 +
   12.24 +      pre.widl { border: solid thin; background: #EEEEEE; color: black; padding: 0.5em 1em; position: relative; }
   12.25 +      pre.widl :link, pre.widl :visited { color: #000; background: transparent; }
   12.26 +      pre.widl:before { content: "IDL"; font: bold small sans-serif; padding: 0.5em; background: white; position: absolute; top: 0; margin: -1px 0 0 -4em; width: 1.5em; border: thin solid; border-radius: 0 0 0 0.5em }
   12.27 +
   12.28 +      div.example { border: solid thin red; background: #F7DFE5; color: black; padding: 0.5em 1em; position: relative; margin: 1em 0 1em 4.6em; width: auto; }
   12.29 +      div.example:before { content: "EXAMPLE"; font: bold small sans-serif; padding: 0.5em; background: red; color: white; position: absolute; top: 0; margin: -1px 0 0 -7.6em; width: 5em; border: thin solid red; border-radius: 0 0 0 0.5em }
   12.30 +
   12.31 +      dl.domintro { color: green; margin: 2em 0 2em 2em; padding: 0.5em 1em; border: none; background: #DDFFDD; }
   12.32 +      hr + dl.domintro, div.impl + dl.domintro { margin-top: 2.5em; margin-bottom: 1.5em; }
   12.33 +      dl.domintro dt, dl.domintro dt * { color: black; text-decoration: none; }
   12.34 +      dl.domintro dd { margin: 0.5em 0 1em 2em; padding: 0; }
   12.35 +      dl.domintro dd p { margin: 0.5em 0; }
   12.36 +      dl.domintro code {font-size: inherit; font-style: italic; }
   12.37 +      dl.domintro:before { display: table; margin: -1em -0.5em 0.5em auto; width: auto; content: 'This box is non-normative. Implementation requirements are given below this box.'; color: red; border: solid 2px; background: white; padding: 0 0.25em; }
   12.38 +    </style>
   12.39 +  <style>/*****************************************************************
   12.40 + * ReSpec 3 CSS
   12.41 + * Robin Berjon - http://berjon.com/
   12.42 + *****************************************************************/
   12.43 +
   12.44 +/* --- INLINES --- */
   12.45 +em.rfc2119 { 
   12.46 +    text-transform:     lowercase;
   12.47 +    font-variant:       small-caps;
   12.48 +    font-style:         normal;
   12.49 +    color:              #900;
   12.50 +}
   12.51 +
   12.52 +h1 acronym, h2 acronym, h3 acronym, h4 acronym, h5 acronym, h6 acronym, a acronym,
   12.53 +h1 abbr, h2 abbr, h3 abbr, h4 abbr, h5 abbr, h6 abbr, a abbr {
   12.54 +    border: none;
   12.55 +}
   12.56 +
   12.57 +dfn {
   12.58 +    font-weight:    bold;
   12.59 +}
   12.60 +
   12.61 +a.internalDFN {
   12.62 +    color:  inherit;
   12.63 +    border-bottom:  1px solid #99c;
   12.64 +    text-decoration:    none;
   12.65 +}
   12.66 +
   12.67 +a.externalDFN {
   12.68 +    color:  inherit;
   12.69 +    border-bottom:  1px dotted #ccc;
   12.70 +    text-decoration:    none;
   12.71 +}
   12.72 +
   12.73 +a.bibref {
   12.74 +    text-decoration:    none;
   12.75 +}
   12.76 +
   12.77 +cite .bibref {
   12.78 +    font-style: normal;
   12.79 +}
   12.80 +
   12.81 +code {
   12.82 +    color:  #ff4500;
   12.83 +}
   12.84 +
   12.85 +
   12.86 +/* --- --- */
   12.87 +ol.algorithm { counter-reset:numsection; list-style-type: none; }
   12.88 +ol.algorithm li { margin: 0.5em 0; }
   12.89 +ol.algorithm li:before { font-weight: bold; counter-increment: numsection; content: counters(numsection, ".") ") "; }
   12.90 +
   12.91 +/* --- TOC --- */
   12.92 +.toc a, .tof a {
   12.93 +    text-decoration:    none;
   12.94 +}
   12.95 +
   12.96 +a .secno, a .figno {
   12.97 +    color:  #000;
   12.98 +}
   12.99 +
  12.100 +ul.tof, ol.tof {
  12.101 +    list-style: none outside none;
  12.102 +}
  12.103 +
  12.104 +.caption {
  12.105 +    margin-top: 0.5em;
  12.106 +    font-style:   italic;
  12.107 +}
  12.108 +
  12.109 +/* --- TABLE --- */
  12.110 +table.simple {
  12.111 +    border-spacing: 0;
  12.112 +    border-collapse:    collapse;
  12.113 +    border-bottom:  3px solid #005a9c;
  12.114 +}
  12.115 +
  12.116 +.simple th {
  12.117 +    background: #005a9c;
  12.118 +    color:  #fff;
  12.119 +    padding:    3px 5px;
  12.120 +    text-align: left;
  12.121 +}
  12.122 +
  12.123 +.simple th[scope="row"] {
  12.124 +    background: inherit;
  12.125 +    color:  inherit;
  12.126 +    border-top: 1px solid #ddd;
  12.127 +}
  12.128 +
  12.129 +.simple td {
  12.130 +    padding:    3px 10px;
  12.131 +    border-top: 1px solid #ddd;
  12.132 +}
  12.133 +
  12.134 +.simple tr:nth-child(even) {
  12.135 +    background: #f0f6ff;
  12.136 +}
  12.137 +
  12.138 +/* --- DL --- */
  12.139 +.section dd > p:first-child {
  12.140 +    margin-top: 0;
  12.141 +}
  12.142 +
  12.143 +.section dd > p:last-child {
  12.144 +    margin-bottom: 0;
  12.145 +}
  12.146 +
  12.147 +.section dd {
  12.148 +    margin-bottom:  1em;
  12.149 +}
  12.150 +
  12.151 +.section dl.attrs dd, .section dl.eldef dd {
  12.152 +    margin-bottom:  0;
  12.153 +}
  12.154 +</style><style>/* --- ISSUES/NOTES --- */
  12.155 +div.issue-title, div.note-title {
  12.156 +    padding-right:  1em;
  12.157 +    min-width: 7.5em;
  12.158 +    color: #b9ab2d;
  12.159 +}
  12.160 +div.issue-title { color: #e05252; }
  12.161 +div.note-title { color: #52e052; }
  12.162 +div.issue-title span, div.note-title span {
  12.163 +    text-transform: uppercase;
  12.164 +}
  12.165 +div.note, div.issue {
  12.166 +    margin-top: 1em;
  12.167 +    margin-bottom: 1em;
  12.168 +}
  12.169 +.note > p:first-child, .issue > p:first-child { margin-top: 0 }
  12.170 +.issue, .note {
  12.171 +    padding: .5em;
  12.172 +    border-left-width: .5em;
  12.173 +    border-left-style: solid;
  12.174 +}
  12.175 +div.issue, div.note {
  12.176 +    padding: 0.5em;
  12.177 +    margin: 1em 0;
  12.178 +    position: relative;
  12.179 +    clear: both;
  12.180 +}
  12.181 +span.note, span.issue { padding: .1em .5em .15em; }
  12.182 +
  12.183 +.issue {
  12.184 +    border-color: #e05252;
  12.185 +    background: #fbe9e9;
  12.186 +}
  12.187 +.note {
  12.188 +    border-color: #52e052;
  12.189 +    background: #e9fbe9;
  12.190 +}
  12.191 +
  12.192 +
  12.193 +</style><style>/* HIGHLIGHTS */
  12.194 +code.prettyprint {
  12.195 +    color:  inherit;
  12.196 +}
  12.197 +
  12.198 +/* this from google-code-prettify */
  12.199 +.pln{color:#000}@media screen{.str{color:#080}.kwd{color:#008}.com{color:#800}.typ{color:#606}.lit{color:#066}.pun,.opn,.clo{color:#660}.tag{color:#008}.atn{color:#606}.atv{color:#080}.dec,.var{color:#606}.fun{color:red}}@media print,projection{.str{color:#060}.kwd{color:#006;font-weight:bold}.com{color:#600;font-style:italic}.typ{color:#404;font-weight:bold}.lit{color:#044}.pun,.opn,.clo{color:#440}.tag{color:#006;font-weight:bold}.atn{color:#404}.atv{color:#060}}ol.linenums{margin-top:0;margin-bottom:0}li.L0,li.L1,li.L2,li.L3,li.L5,li.L6,li.L7,li.L8{list-style-type:none}li.L1,li.L3,li.L5,li.L7,li.L9{background:#eee}
  12.200 +</style><link href="http://www.w3.org/StyleSheets/TR/W3C-WD" rel="stylesheet"><!--[if lt IE 9]><script src='undefined://www.w3.org/2008/site/js/html5shiv.js'></script><![endif]--></head>
  12.201 +
  12.202 +  <body><div class="head">
  12.203 +  <p>
  12.204 +    
  12.205 +      <a href="http://www.w3.org/"><img src="http://www.w3.org/Icons/w3c_home" alt="W3C" height="48" width="72"></a>
  12.206 +    
  12.207 +  </p>
  12.208 +  <h1 class="title" id="title">Networked Service Discovery and Messaging</h1>
  12.209 +  
  12.210 +  <h2 id="w3c-working-draft-07-august-2012"><abbr title="World Wide Web Consortium">W3C</abbr> Working Draft 07 August 2012</h2>
  12.211 +  <dl>
  12.212 +    
  12.213 +      <dt>This version:</dt>
  12.214 +      <dd><a href="http://www.w3.org/TR/2012/WD-discovery-api-20120807/">http://www.w3.org/TR/2012/WD-discovery-api-20120807/</a></dd>
  12.215 +      <dt>Latest published version:</dt>
  12.216 +      <dd><a href="http://www.w3.org/TR/discovery-api/">http://www.w3.org/TR/discovery-api/</a></dd>
  12.217 +    
  12.218 +    
  12.219 +      <dt>Latest editor's draft:</dt>
  12.220 +      <dd><a href="http://w3c-test.org/dap/discovery-api/">http://w3c-test.org/dap/discovery-api/</a></dd>
  12.221 +    
  12.222 +    
  12.223 +    
  12.224 +    
  12.225 +    
  12.226 +    
  12.227 +    <dt>Editors:</dt>
  12.228 +    <dd><span>Rich Tibbett</span>, <a href="http://opera.com/">Opera Software ASA</a></dd>
  12.229 +<dd><span>Clarke Stevens</span>, <a href="http://cablelabs.com/">CableLabs</a></dd>
  12.230 +
  12.231 +    
  12.232 +  </dl>
  12.233 +  
  12.234 +  
  12.235 +  
  12.236 +  
  12.237 +    
  12.238 +      <p class="copyright">
  12.239 +        <a href="http://www.w3.org/Consortium/Legal/ipr-notice#Copyright">Copyright</a> © 
  12.240 +        2012
  12.241 +        
  12.242 +        <a href="http://www.w3.org/"><abbr title="World Wide Web Consortium">W3C</abbr></a><sup>®</sup> 
  12.243 +        (<a href="http://www.csail.mit.edu/"><abbr title="Massachusetts Institute of Technology">MIT</abbr></a>,
  12.244 +        <a href="http://www.ercim.eu/"><abbr title="European Research Consortium for Informatics and Mathematics">ERCIM</abbr></a>,
  12.245 +        <a href="http://www.keio.ac.jp/">Keio</a>), All Rights Reserved.
  12.246 +        <abbr title="World Wide Web Consortium">W3C</abbr> <a href="http://www.w3.org/Consortium/Legal/ipr-notice#Legal_Disclaimer">liability</a>,
  12.247 +        <a href="http://www.w3.org/Consortium/Legal/ipr-notice#W3C_Trademarks">trademark</a> and
  12.248 +        <a href="http://www.w3.org/Consortium/Legal/copyright-documents">document use</a> rules apply.
  12.249 +      </p>
  12.250 +    
  12.251 +  
  12.252 +  <hr>
  12.253 +</div>
  12.254 +    <section class="introductory" id="abstract"><h2>Abstract</h2>
  12.255 +      <p>
  12.256 +        This specification defines a mechanism for an HTML document to discover and subsequently communicate with <abbr title="Hypertext Transfer Protocol">HTTP</abbr>-based services
  12.257 +        advertised via common discovery protocols within a user's network.
  12.258 +      </p>
  12.259 +    </section><section id="sotd" class="introductory"><h2>Status of This Document</h2>
  12.260 +  
  12.261 +    
  12.262 +      
  12.263 +        <p>
  12.264 +          <em>This section describes the status of this document at the time of its publication. Other
  12.265 +          documents may supersede this document. A list of current <abbr title="World Wide Web Consortium">W3C</abbr> publications and the latest revision
  12.266 +          of this technical report can be found in the <a href="http://www.w3.org/TR/"><abbr title="World Wide Web Consortium">W3C</abbr> technical reports
  12.267 +          index</a> at http://www.w3.org/TR/.</em>
  12.268 +        </p>
  12.269 +        
  12.270 +      <p>
  12.271 +        This document represents the early consensus of the group on the scope and features of the proposed
  12.272 +        <abbr title="Application Programming Interface">API</abbr>.
  12.273 +      </p>
  12.274 +    
  12.275 +        <p>
  12.276 +          This document was published by the <a href="http://www.w3.org/2009/dap/">Device APIs and Policy Working Group</a> as a First Public Working Draft.
  12.277 +          
  12.278 +            This document is intended to become a <abbr title="World Wide Web Consortium">W3C</abbr> Recommendation.
  12.279 +          
  12.280 +          If you wish to make comments regarding this document, please send them to 
  12.281 +          <a href="mailto:public-device-apis@w3.org">public-device-apis@w3.org</a> 
  12.282 +          (<a href="mailto:public-device-apis-request@w3.org?subject=subscribe">subscribe</a>,
  12.283 +          <a href="http://lists.w3.org/Archives/Public/public-device-apis/">archives</a>).
  12.284 +          
  12.285 +          
  12.286 +          All feedback is welcome.
  12.287 +        </p>
  12.288 +        
  12.289 +          <p>
  12.290 +            Publication as a Working Draft does not imply endorsement by the <abbr title="World Wide Web Consortium">W3C</abbr> Membership.
  12.291 +            This is a draft document and may be updated, replaced or obsoleted by other documents at 
  12.292 +            any time. It is inappropriate to cite this document as other than work in progress.
  12.293 +          </p>
  12.294 +        
  12.295 +        
  12.296 +        <p>
  12.297 +          
  12.298 +            This document was produced by a group operating under the 
  12.299 +            <a href="http://www.w3.org/Consortium/Patent-Policy-20040205/">5 February 2004 <abbr title="World Wide Web Consortium">W3C</abbr> Patent Policy</a>.
  12.300 +          
  12.301 +          
  12.302 +          
  12.303 +            
  12.304 +              <abbr title="World Wide Web Consortium">W3C</abbr> maintains a <a href="http://www.w3.org/2004/01/pp-impl/43696/status" rel="disclosure">public list of any patent disclosures</a> 
  12.305 +            
  12.306 +            made in connection with the deliverables of the group; that page also includes instructions for 
  12.307 +            disclosing a patent. An individual who has actual knowledge of a patent which the individual believes contains
  12.308 +            <a href="http://www.w3.org/Consortium/Patent-Policy-20040205/#def-essential">Essential Claim(s)</a> must disclose the
  12.309 +            information in accordance with <a href="http://www.w3.org/Consortium/Patent-Policy-20040205/#sec-Disclosure">section
  12.310 +            6 of the <abbr title="World Wide Web Consortium">W3C</abbr> Patent Policy</a>.
  12.311 +          
  12.312 +          
  12.313 +        </p>
  12.314 +        
  12.315 +      
  12.316 +    
  12.317 +  
  12.318 +</section><section id="toc"><h2 class="introductory">Table of Contents</h2><ul class="toc"><li class="tocline"><a class="tocxref" href="#introduction"><span class="secno">1. </span>Introduction</a></li><li class="tocline"><a class="tocxref" href="#conformance"><span class="secno">2. </span>Conformance</a><ul class="toc"><li class="tocline"><a class="tocxref" href="#dependencies"><span class="secno">2.1 </span>Dependencies</a></li></ul></li><li class="tocline"><a class="tocxref" href="#terminology"><span class="secno">3. </span>Terminology</a></li><li class="tocline"><a class="tocxref" href="#requesting-networked-services"><span class="secno">4. </span>Requesting networked services</a><ul class="toc"><li class="tocline"><a class="tocxref" href="#methods"><span class="secno">4.1 </span>Methods</a></li><li class="tocline"><a class="tocxref" href="#error-handling"><span class="secno">4.2 </span>Error Handling</a></li></ul></li><li class="tocline"><a class="tocxref" href="#obtaining-networked-services"><span class="secno">5. </span>Obtaining networked services</a><ul class="toc"><li class="tocline"><a class="tocxref" href="#attributes"><span class="secno">5.1 </span>Attributes</a></li><li class="tocline"><a class="tocxref" href="#methods-1"><span class="secno">5.2 </span>Methods</a></li><li class="tocline"><a class="tocxref" href="#events"><span class="secno">5.3 </span>Events</a></li></ul></li><li class="tocline"><a class="tocxref" href="#communicating-with-a-networked-service"><span class="secno">6. </span>Communicating with a networked service</a><ul class="toc"><li class="tocline"><a class="tocxref" href="#attributes-1"><span class="secno">6.1 </span>Attributes</a></li><li class="tocline"><a class="tocxref" href="#states"><span class="secno">6.2 </span>States</a></li><li class="tocline"><a class="tocxref" href="#events-1"><span class="secno">6.3 </span>Events</a></li></ul></li><li class="tocline"><a class="tocxref" href="#service-discovery"><span class="secno">7. </span>Service Discovery</a><ul class="toc"><li class="tocline"><a class="tocxref" href="#zeroconf-mdns-dns-sd"><span class="secno">7.1 </span>Zeroconf (<abbr title="Multicast DNS">mDNS</abbr> + <abbr title="Domain Name System">DNS</abbr>-<abbr title="Service Discovery">SD</abbr>)</a></li><li class="tocline"><a class="tocxref" href="#universal-plug-and-play-upnp"><span class="secno">7.2 </span>Universal Plug-and-Play (<abbr title="Universal Plug-and-Play">UPnP</abbr>)</a></li><li class="tocline"><a class="tocxref" href="#network-topology-monitoring"><span class="secno">7.3 </span>Network Topology Monitoring</a></li></ul></li><li class="tocline"><a class="tocxref" href="#garbage-collection"><span class="secno">8. </span>Garbage collection</a></li><li class="tocline"><a class="tocxref" href="#use-cases-and-requirements"><span class="secno">9. </span>Use Cases and Requirements</a></li><li class="tocline"><a class="tocxref" href="#examples"><span class="secno">A. </span>Examples</a></li><li class="tocline"><a class="tocxref" href="#acknowledgements"><span class="secno">B. </span>Acknowledgements</a></li><li class="tocline"><a class="tocxref" href="#references"><span class="secno">C. </span>References</a><ul class="toc"><li class="tocline"><a class="tocxref" href="#normative-references"><span class="secno">C.1 </span>Normative references</a></li><li class="tocline"><a class="tocxref" href="#informative-references"><span class="secno">C.2 </span>Informative references</a></li></ul></li></ul></section>
  12.319 +
  12.320 +    
  12.321 +
  12.322 +    <section id="introduction" class="informative">
  12.323 +      <!--OddPage--><h2><span class="secno">1. </span>Introduction</h2><p><em>This section is non-normative.</em></p>
  12.324 +
  12.325 +      <p>To enable Web pages to connect and communicate with Local-networked Services provided over <abbr title="Hypertext Transfer Protocol">HTTP</abbr>, this specification introduces the
  12.326 +      <a href="#navigatornetworkservice"><code>NavigatorNetworkService</code></a> interface.</p>
  12.327 +
  12.328 +      <p>
  12.329 +         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,
  12.330 +         is expected before the web page is able to interact with any Local-networked Services.
  12.331 +      </p>
  12.332 +
  12.333 +      <p>
  12.334 +         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.
  12.335 +      </p>
  12.336 +
  12.337 +      <p>
  12.338 +         The user agent, having captured all advertised services on the network from the Service Discovery mechanisms included in this recommendation, attempts to match
  12.339 +      the requested service type to a discovered service according to the processing described herein.
  12.340 +      </p>
  12.341 +
  12.342 +      <p>
  12.343 +          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.
  12.344 +          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.
  12.345 +      </p>
  12.346 +
  12.347 +      <p>
  12.348 +         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
  12.349 +         authorized via the provided <abbr title="Application Programming Interface">API</abbr>.
  12.350 +         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
  12.351 +         connected Local-networked Service.
  12.352 +      </p>
  12.353 +
  12.354 +      <div class="example">
  12.355 +       <p>Example of requesting a <abbr title="Domain Name System">DNS</abbr>-<abbr title="Service Discovery">SD</abbr> advertised service:</p>
  12.356 +       <hr>
  12.357 +       <pre class="highlight prettyprint"><span class="kwd">function</span><span class="pln"> showServices</span><span class="pun">(</span><span class="pln"> services </span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
  12.358 +  </span><span class="com">// Show a list of all the services provided to the web page</span><span class="pln">
  12.359 +  </span><span class="kwd">for</span><span class="pun">(</span><span class="kwd">var</span><span class="pln"> i </span><span class="pun">=</span><span class="pln"> </span><span class="lit">0</span><span class="pun">,</span><span class="pln"> l </span><span class="pun">=</span><span class="pln"> services</span><span class="pun">.</span><span class="pln">length</span><span class="pun">;</span><span class="pln"> i </span><span class="pun">&lt;</span><span class="pln"> l</span><span class="pun">;</span><span class="pln"> i</span><span class="pun">++)</span><span class="pln"> console</span><span class="pun">.</span><span class="pln">log</span><span class="pun">(</span><span class="pln"> services</span><span class="pun">[</span><span class="pln">i</span><span class="pun">].</span><span class="pln">name </span><span class="pun">);</span><span class="pln">
  12.360 +</span><span class="pun">}</span><span class="pln">
  12.361 +
  12.362 +navigator</span><span class="pun">.</span><span class="pln">getNetworkServices</span><span class="pun">(</span><span class="str">'zeroconf:_boxee-jsonrpc._tcp'</span><span class="pun">,</span><span class="pln"> showServices</span><span class="pun">);</span></pre>
  12.363 +      </div>
  12.364 +
  12.365 +      <div class="example">
  12.366 +        <p>Example of requesting a <abbr title="Universal Plug-and-Play">UPnP</abbr> advertised service, also handling error conditions:</p>
  12.367 +        <hr>
  12.368 +        <pre class="highlight prettyprint"><span class="kwd">function</span><span class="pln"> showServices</span><span class="pun">(</span><span class="pln"> services </span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
  12.369 +  </span><span class="com">// Show a list of all the services provided to the web page</span><span class="pln">
  12.370 +  </span><span class="kwd">for</span><span class="pun">(</span><span class="kwd">var</span><span class="pln"> i </span><span class="pun">=</span><span class="pln"> </span><span class="lit">0</span><span class="pun">,</span><span class="pln"> l </span><span class="pun">=</span><span class="pln"> services</span><span class="pun">.</span><span class="pln">length</span><span class="pun">;</span><span class="pln"> i </span><span class="pun">&lt;</span><span class="pln"> l</span><span class="pun">;</span><span class="pln"> i</span><span class="pun">++)</span><span class="pln"> console</span><span class="pun">.</span><span class="pln">log</span><span class="pun">(</span><span class="pln"> services</span><span class="pun">[</span><span class="pln">i</span><span class="pun">].</span><span class="pln">name </span><span class="pun">);</span><span class="pln">
  12.371 +</span><span class="pun">}</span><span class="pln">
  12.372 +
  12.373 +</span><span class="kwd">function</span><span class="pln"> error</span><span class="pun">(</span><span class="pln"> e </span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
  12.374 +  console</span><span class="pun">.</span><span class="pln">log</span><span class="pun">(</span><span class="pln"> </span><span class="str">"Error occurred: "</span><span class="pln"> </span><span class="pun">+</span><span class="pln"> e</span><span class="pun">.</span><span class="pln">code </span><span class="pun">);</span><span class="pln">
  12.375 +</span><span class="pun">}</span><span class="pln">
  12.376 +
  12.377 +navigator</span><span class="pun">.</span><span class="pln">getNetworkServices</span><span class="pun">(</span><span class="str">'upnp:urn:schemas-upnp-org:service:ContentDirectory:1'</span><span class="pun">,</span><span class="pln"> showServices</span><span class="pun">,</span><span class="pln"> error</span><span class="pun">);</span></pre>
  12.378 +      </div>
  12.379 +
  12.380 +      <div class="example">
  12.381 +        <p>Example of requesting either a <abbr title="Domain Name System">DNS</abbr>-<abbr title="Service Discovery">SD</abbr> or <abbr title="Universal Plug-and-Play">UPnP</abbr> advertised service:</p>
  12.382 +        <hr>
  12.383 +        <pre class="highlight prettyprint"><span class="kwd">function</span><span class="pln"> showServices</span><span class="pun">(</span><span class="pln"> services </span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
  12.384 +  </span><span class="com">// Show a list of all the services provided to the web page (+ service type)</span><span class="pln">
  12.385 +  </span><span class="kwd">for</span><span class="pun">(</span><span class="kwd">var</span><span class="pln"> i </span><span class="pun">=</span><span class="pln"> </span><span class="lit">0</span><span class="pun">,</span><span class="pln"> l </span><span class="pun">=</span><span class="pln"> services</span><span class="pun">.</span><span class="pln">length</span><span class="pun">;</span><span class="pln"> i </span><span class="pun">&lt;</span><span class="pln"> l</span><span class="pun">;</span><span class="pln"> i</span><span class="pun">++)</span><span class="pln">
  12.386 +     console</span><span class="pun">.</span><span class="pln">log</span><span class="pun">(</span><span class="pln"> services</span><span class="pun">[</span><span class="pln">i</span><span class="pun">].</span><span class="pln">name </span><span class="pun">+</span><span class="pln"> </span><span class="str">'('</span><span class="pln"> </span><span class="pun">+</span><span class="pln"> services</span><span class="pun">[</span><span class="pln">i</span><span class="pun">].</span><span class="pln">type </span><span class="pun">+</span><span class="pln"> </span><span class="str">')'</span><span class="pln"> </span><span class="pun">);</span><span class="pln">
  12.387 +</span><span class="pun">}</span><span class="pln">
  12.388 +
  12.389 +navigator</span><span class="pun">.</span><span class="pln">getNetworkServices</span><span class="pun">([</span><span class="pln">
  12.390 +  </span><span class="str">'zeroconf:_boxee-jsonrpc._tcp'</span><span class="pun">,</span><span class="pln">
  12.391 +  </span><span class="str">'upnp:urn:schemas-upnp-org:service:ContentDirectory:1'</span><span class="pln">
  12.392 +</span><span class="pun">],</span><span class="pln"> showServices</span><span class="pun">);</span></pre>
  12.393 +      </div>
  12.394 +
  12.395 +      <p>For more detailed examples see the <a href="#examples">Examples</a> section.
  12.396 +    </p></section>
  12.397 +
  12.398 +    <section id="conformance"><!--OddPage--><h2><span class="secno">2. </span>Conformance</h2>
  12.399 +<p>
  12.400 +  As well as sections marked as non-normative, all authoring guidelines, diagrams, examples,
  12.401 +  and notes in this specification are non-normative. Everything else in this specification is
  12.402 +  normative.
  12.403 +</p>
  12.404 +<p>
  12.405 +  The key words <em title="must" class="rfc2119">must</em>, <em title="must not" class="rfc2119">must not</em>, <em title="required" class="rfc2119">required</em>, <em title="should" class="rfc2119">should</em>, <em title="should not" class="rfc2119">should not</em>, <em title="recommended" class="rfc2119">recommended</em>, <em title="may" class="rfc2119">may</em>,
  12.406 +  and <em title="optional" class="rfc2119">optional</em> in this specification are to be interpreted as described in [<cite><a href="#bib-RFC2119" class="bibref">RFC2119</a></cite>].
  12.407 +</p>
  12.408 +
  12.409 +
  12.410 +     <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
  12.411 +     meaning of the key word ("must", "should", "may", etc) used in introducing the algorithm.</p>
  12.412 +
  12.413 +     <p>
  12.414 +      Some conformance requirements are phrased as requirements on attributes, methods or objects. Such requirements are to be interpreted as requirements on user agents.
  12.415 +     </p>
  12.416 +
  12.417 +     <p>
  12.418 +      Conformance requirements phrased as algorithms or specific steps may be implemented in any manner, so long as the end result is equivalent. (In particular, the algorithms defined in
  12.419 +      this specification are intended to be easy to follow, and not intended to be performant.)
  12.420 +     </p>
  12.421 +
  12.422 +     <p>
  12.423 +      The only conformance class defined by this specification is a <dfn id="dfn-user-agent">user agent</dfn>.
  12.424 +     </p>
  12.425 +
  12.426 +     <p>
  12.427 +      User agents may 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
  12.428 +      around platform-specific limitations.
  12.429 +     </p>
  12.430 +
  12.431 +     <p>
  12.432 +      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 must act as if
  12.433 +      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
  12.434 +      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
  12.435 +      is insufficient.
  12.436 +     </p>
  12.437 +
  12.438 +      <section id="dependencies">
  12.439 +         <h3><span class="secno">2.1 </span>Dependencies</h3>
  12.440 +
  12.441 +         This specification relies on several other underlying specifications.
  12.442 +
  12.443 +         <dl>
  12.444 +            <dt>HTML</dt>
  12.445 +            <dd>Many fundamental concepts from HTML are used by this specification. [<cite><a href="#bib-HTML5" class="bibref">HTML5</a></cite>]</dd>
  12.446 +            <dt>WebIDL</dt>
  12.447 +            <dd>The IDL blocks in this specification use the semantics of the WebIDL specification. [<cite><a href="#bib-WEBIDL" class="bibref">WEBIDL</a></cite>]</dd>
  12.448 +         </dl>
  12.449 +      </section>
  12.450 +    </section>
  12.451 +
  12.452 +    <section id="terminology">
  12.453 +      <!--OddPage--><h2><span class="secno">3. </span>Terminology</h2>
  12.454 +
  12.455 +      <p>
  12.456 +         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>".
  12.457 +      </p>
  12.458 +
  12.459 +      <p>
  12.460 +         The term DOM is used to refer to the <abbr title="Application Programming Interface">API</abbr> 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
  12.461 +         other <code>Node</code> objects as defined in the DOM Core specifications. [<cite><a href="#bib-DOM4" class="bibref">DOM4</a></cite>]
  12.462 +      </p>
  12.463 +
  12.464 +      <p>
  12.465 +         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.
  12.466 +      </p>
  12.467 +
  12.468 +      <p>
  12.469 +        A <dfn id="dfn-valid-service-type">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.
  12.470 +      </p>
  12.471 +
  12.472 +      <p>
  12.473 +        A <a class="internalDFN" href="#dfn-valid-service-type">valid service type</a> provided in the <code>type</code> attribute of the <code>getNetworkServices()</code> method will be matched against the services currently contained in the <a class="internalDFN" href="#dfn-list-of-available-service-records">list of available service records</a> according to the algorithms defined in this specification.
  12.474 +      </p>
  12.475 +    </section>
  12.476 +
  12.477 +    <section id="requesting-networked-services">
  12.478 +     <!--OddPage--><h2><span class="secno">4. </span>Requesting networked services</h2>
  12.479 +
  12.480 +
  12.481 +<pre class="widl">[Supplemental, NoInterfaceObject]
  12.482 +interface <dfn id="navigatornetworkservice">NavigatorNetworkService</dfn> {
  12.483 +  // Obtain a Local-networked Service
  12.484 +  void <a href="#dom-navigator-getnetworkservices">getNetworkServices</a>( in any type,
  12.485 +                           in <a href="#navigatornetworkservicesuccesscallback">NavigatorNetworkServiceSuccessCallback</a> successCallback,
  12.486 +                           in optional <a href="#navigatornetworkserviceerrorcallback">NavigatorNetworkServiceErrorCallback</a> errorCallback );
  12.487 +};
  12.488 +<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>;
  12.489 +
  12.490 +[Callback=FunctionOnly, NoInterfaceObject]
  12.491 +interface <dfn id="navigatornetworkservicesuccesscallback">NavigatorNetworkServiceSuccessCallback</dfn> {
  12.492 +  void handleEvent( in <a href="#networkservices">NetworkServices</a> services );
  12.493 +};
  12.494 +
  12.495 +[NoInterfaceObject]
  12.496 +interface <dfn id="navigatornetworkserviceerror">NavigatorNetworkServiceError</dfn> {
  12.497 +  const unsigned short <a href="#dom-navigatornetworkserviceerror-permission_denied">PERMISSION_DENIED_ERR</a> = 1;
  12.498 +  const unsigned short <a href="#dom-navigatornetworkserviceerror-unknown_type_prefix">UNKNOWN_TYPE_PREFIX_ERR</a> = 2;
  12.499 +  readonly attribute unsigned short <a href="#dom-navigatornetworkserviceerror-code">code</a>;
  12.500 +};
  12.501 +
  12.502 +[Callback=FunctionOnly, NoInterfaceObject]
  12.503 +interface <dfn id="navigatornetworkserviceerrorcallback">NavigatorNetworkServiceErrorCallback</dfn> {
  12.504 +  void handleEvent( in <a href="#navigatornetworkserviceerror">NavigatorNetworkServiceError</a> error );
  12.505 +};
  12.506 +</pre>
  12.507 +
  12.508 +  <section id="methods">
  12.509 +   <h3><span class="secno">4.1 </span>Methods</h3>
  12.510 +
  12.511 +      <dl class="domintro">
  12.512 +        <dt>
  12.513 +          <var title="">window</var>
  12.514 +           .
  12.515 +          <code title="dom-navigator">
  12.516 +            <a href="http://www.whatwg.org/specs/web-apps/current-work/complete/timers.html#navigator">navigator</a>
  12.517 +          </code>
  12.518 +           .
  12.519 +          <code title="dom-navigator-getNetworkServices">
  12.520 +            <a href="#dom-navigator-getnetworkservices">getNetworkServices</a>
  12.521 +          </code>
  12.522 +          (
  12.523 +          <var title="">type</var>
  12.524 +          ,
  12.525 +          <var title="">successCallback</var>
  12.526 +           [,
  12.527 +          <var title="">errorCallback</var>
  12.528 +           ] )
  12.529 +        </dt>
  12.530 +        <dd>
  12.531 +          <p>Prompts the user to select one or more discovered network services that have advertised support for the requested service type.</p>
  12.532 +          <p>
  12.533 +            The
  12.534 +            <var title="">type</var>
  12.535 +             argument contains one or more <a class="internalDFN" href="#dfn-valid-service-type">valid service type</a> tokens that the web page would like to interact with.
  12.536 +          </p>
  12.537 +          <p>
  12.538 +            If the user accepts, the
  12.539 +            <var title="">successCallback</var>
  12.540 +             is
  12.541 +          invoked, with one or more
  12.542 +            <code>
  12.543 +              <a href="#networkservice"><code>NetworkService</code></a>
  12.544 +            </code>
  12.545 +             objects as
  12.546 +          its argument.
  12.547 +          </p>
  12.548 +          <p>
  12.549 +            If the user declines, the
  12.550 +            <var title="">errorCallback</var>
  12.551 +             (if
  12.552 +          any) is invoked.
  12.553 +          </p>
  12.554 +        </dd>
  12.555 +      </dl>
  12.556 +
  12.557 +       <div>
  12.558 +          <p>
  12.559 +            When the <dfn id="dom-navigator-getnetworkservices" title="dom-navigator-getnetworkservices"><code>getNetworkServices(type, successCallback[, errorCallback])</code></dfn> method is called, the <a class="internalDFN" href="#dfn-user-agent">user agent</a> <em title="must" class="rfc2119">must</em> run the following steps:
  12.560 +          </p>
  12.561 +
  12.562 +          <ol class="rule">
  12.563 +            <li>
  12.564 +               If <var>successCallback</var> is empty or is not an object of type <code>Function</code> then the <a class="internalDFN" href="#dfn-user-agent">user agent</a> <em title="must" class="rfc2119">must</em> abort these steps.
  12.565 +            </li>
  12.566 +
  12.567 +            <li>
  12.568 +              Let <var>requested control types</var> be initially set to an empty array.
  12.569 +            </li>
  12.570 +
  12.571 +            <li>
  12.572 +               If <var>type</var> is an array consisting of one or more <a class="internalDFN" href="#dfn-valid-service-type">valid service type</a> tokens, then let <var>requested control types</var> by the value of <var>type</var>, removing any non-<a class="internalDFN" href="#dfn-valid-service-type">valid service type</a> tokens from the resulting array.
  12.573 +            </li>
  12.574 +
  12.575 +            <li>
  12.576 +               If <var>type</var> is a string consisting of one <a class="internalDFN" href="#dfn-valid-service-type">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>.
  12.577 +            </li>
  12.578 +
  12.579 +            <li>
  12.580 +               If <var>requested control types</var> is an array that contains at least one or more <a class="internalDFN" href="#dfn-valid-service-type" title="valid service type">valid service type</a> tokens then continue to the step labeled <em>process</em> below. Otherwise, the <a class="internalDFN" href="#dfn-user-agent">user agent</a> <em title="must" class="rfc2119">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
  12.581 +                 <a href="#dom-navigatornetworkserviceerror-code"><code>code</code></a> attribute has the numeric value 2
  12.582 +                  (<a href="#dom-navigatornetworkserviceerror-unknown_type_prefix"><code>UNKNOWN_TYPE_PREFIX_ERR</code></a>) as its argument,
  12.583 +                   abort any remaining steps and return.
  12.584 +            </li>
  12.585 +
  12.586 +            <li>
  12.587 +               <em>Process</em>: Let <var>services found</var> be an empty array.
  12.588 +            </li>
  12.589 +
  12.590 +            <li>
  12.591 +               For each <var>available service</var> in the <a class="internalDFN" href="#dfn-list-of-available-service-records">list of available service records</a> run the following steps:
  12.592 +               <ol class="rule">
  12.593 +                  <li>
  12.594 +                    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.
  12.595 +                  </li>
  12.596 +                  <li>
  12.597 +                     Continue at the next <var>available service</var>.
  12.598 +                  </li>
  12.599 +                  <li>
  12.600 +                     <em>Attach</em>: If <var>matched service</var> is not empty then run the following steps:
  12.601 +
  12.602 +                     <ol class="rule">
  12.603 +                        <li>
  12.604 +                           Let <var>new service object</var> be a new <a href="#networkservice"><code>NetworkService</code></a> object, mapping the parameters of
  12.605 +                     <var>matched service</var> to this new object where possible.
  12.606 +                        </li>
  12.607 +                        <li>
  12.608 +                           Append <var>new service object</var> to the <var>services found</var> array.
  12.609 +                        </li>
  12.610 +                     </ol>
  12.611 +                  </li>
  12.612 +               </ol>
  12.613 +            </li>
  12.614 +
  12.615 +            <li>
  12.616 +               If <var>services found</var> is an empty array, then the <a class="internalDFN" href="#dfn-user-agent">user agent</a> <em title="must" class="rfc2119">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
  12.617 +                 <a href="#dom-navigatornetworkserviceerror-code"><code>code</code></a> attribute has the numeric value 1
  12.618 +                 (<a href="#dom-navigatornetworkserviceerror-permission_denied"><code>PERMISSION_DENIED_ERR</code></a>) as its argument, abort any remaining steps and return.
  12.619 +            </li>
  12.620 +
  12.621 +            <li>
  12.622 +               Return, and run the remaining steps asynchronously.
  12.623 +            </li>
  12.624 +
  12.625 +            <li>
  12.626 +               Optionally, e.g. based on a previously-established user preference, for security reasons, or due to platform limitations, the <a class="internalDFN" href="#dfn-user-agent">user agent</a> <em title="may" class="rfc2119">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
  12.627 +                 <a href="#dom-navigatornetworkserviceerror-code"><code>code</code></a> attribute has the numeric value 1
  12.628 +                 (<a href="#dom-navigatornetworkserviceerror-permission_denied"><code>PERMISSION_DENIED_ERR</code></a>) as its argument, abort any remaining steps and return.
  12.629 +            </li>
  12.630 +
  12.631 +            <li>
  12.632 +                  The <a class="internalDFN" href="#dfn-user-agent">user agent</a> <em title="must" class="rfc2119">must</em> prompt the user in a user-agent-specific manner for permission to provide the
  12.633 +                  <a href="http://www.whatwg.org/specs/web-apps/current-work/complete/browsers.html#entry-script" class="externalDFN">entry script</a>'s
  12.634 +                  <a href="http://www.whatwg.org/specs/web-apps/current-work/complete/origin-0.html#origin" class="externalDFN">origin</a> with an array of
  12.635 +                  <a href="#networkservice"><code>NetworkService</code></a> objects representing the user-authorized subset of <var>services found</var>.
  12.636 +
  12.637 +               <p>
  12.638 +                  If the user grants permission to access one or more networked services then the <a class="internalDFN" href="#dfn-user-agent">user agent</a> <em title="should" class="rfc2119">should</em> include an
  12.639 +                  "ongoing local-network communication" indicator.
  12.640 +               </p>
  12.641 +
  12.642 +               <p>If the user denies permission, then the <a class="internalDFN" href="#dfn-user-agent">user agent</a> <em title="must" class="rfc2119">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
  12.643 +                <a href="#dom-navigatornetworkserviceerror-code"><code>code</code></a> attribute has the numeric value 1
  12.644 +                (<a href="#dom-navigatornetworkserviceerror-permission_denied"><code>PERMISSION_DENIED_ERR</code></a>) as its argument, abort any remaining steps and return.
  12.645 +              </p>
  12.646 +
  12.647 +              <p>
  12.648 +                If the user never responds, this algorithm stalls on this step.
  12.649 +              </p>
  12.650 +
  12.651 +            </li>
  12.652 +
  12.653 +            <li>
  12.654 +               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.
  12.655 +            </li>
  12.656 +
  12.657 +            <li>
  12.658 +               For each Object <var>service</var> in <var>services</var>, run the following substeps:
  12.659 +
  12.660 +               <ol class="rule">
  12.661 +                  <li>
  12.662 +                     Add the <var>service</var>'s <code>url</code> parameter to the <a class="internalDFN" href="#dfn-entry-script-origin-s-url-whitelist">entry script origin's <abbr title="Uniform Resource Locator">URL</abbr> whitelist</a>.
  12.663 +                  </li>
  12.664 +                  <li>
  12.665 +                    If <var>service</var> was originally created from a <abbr title="Universal Plug-and-Play">UPnP</abbr> discovery process and the <var>service</var>'s <code>eventsUrl</code> parameter is not empty then <a class="internalDFN" href="#dfn-setup-a-upnp-events-subscription">setup a <abbr title="Universal Plug-and-Play">UPnP</abbr> Events Subscription</a> for <var>service</var>.
  12.666 +                  </li>
  12.667 +               </ol>
  12.668 +            </li>
  12.669 +
  12.670 +            <li>
  12.671 +               Let <var>services manager</var> be a new <a href="#networkservices"><code>NetworkServices</code></a> object.
  12.672 +            </li>
  12.673 +
  12.674 +            <li>
  12.675 +               Set <var>services manager</var>'s <code>servicesAvailable</code> attribute to the length of <var>services</var>.
  12.676 +            </li>
  12.677 +
  12.678 +            <li>
  12.679 +              Store the set of <var>services</var> as <dfn id="current_authorized_services">current authorized services</dfn> internally against the newly created <var>services manager</var> object.
  12.680 +            </li>
  12.681 +
  12.682 +            <li>
  12.683 +               The <a class="internalDFN" href="#dfn-user-agent">user agent</a> <em title="must" class="rfc2119">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
  12.684 +               <var>services manager</var> as its argument.
  12.685 +            </li>
  12.686 +
  12.687 +          </ol>
  12.688 +
  12.689 +          <p>
  12.690 +            The <a href="http://www.whatwg.org/specs/web-apps/current-work/complete/webappapis.html#task-source" class="externalDFN">task source</a> for these
  12.691 +            <a href="http://www.whatwg.org/specs/web-apps/current-work/complete/webappapis.html#concept-task" class="externalDFN">tasks</a> is the
  12.692 +            <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>.
  12.693 +          </p>
  12.694 +
  12.695 +          <p>
  12.696 +            When a <a href="#networkservice"><code>NetworkService</code></a> object is provided to a Web page, the <a class="internalDFN" href="#dfn-user-agent">user agent</a> <em title="must" class="rfc2119">must</em> add the <code>url</code> property
  12.697 +             to the <dfn id="dfn-entry-script-origin-s-url-whitelist">entry script origin's <abbr title="Uniform Resource Locator">URL</abbr> whitelist</dfn>. This list enables the
  12.698 +            Web page to override and initiate cross-site resource requests towards these URLs, and any sub-resources of these URLs, within the current
  12.699 +            <a href="http://www.whatwg.org/specs/web-apps/current-work/complete/browsers.html#entry-script" class="externalDFN">entry script</a>'s
  12.700 +            <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,
  12.701 +            Web Messaging, XMLHttpRequest).
  12.702 +         </p>
  12.703 +
  12.704 +         <p>
  12.705 +            If the user navigates away from the current browsing context, the <a class="internalDFN" href="#dfn-user-agent">user agent</a> <em title="must" class="rfc2119">must</em> remove all previously whitelisted urls from the <a class="internalDFN" href="#dfn-entry-script-origin-s-url-whitelist">entry script origin's <abbr title="Uniform Resource Locator">URL</abbr> whitelist</a>.
  12.706 +            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:
  12.707 +            </p><ul>
  12.708 +              <li>If the current script is reloaded at any point in the same or different window.</li>
  12.709 +              <li>if the current script reinvokes the <a href="#dom-navigator-getnetworkservices"><code>getNetworkServices()</code></a> method at any point in its execution.</li>
  12.710 +              <li>If the user navigates forward or back in their history to reload the current page.</li>
  12.711 +              <li>If a script is running in a different origin.</li>
  12.712 +            </ul>
  12.713 +         <p></p>
  12.714 +
  12.715 +      </div>
  12.716 +      </section>
  12.717 +
  12.718 +      <section id="error-handling">
  12.719 +         <h3><span class="secno">4.2 </span>Error Handling</h3>
  12.720 +
  12.721 +      <dl class="domintro">
  12.722 +        <dt>
  12.723 +          <var title="">error</var>
  12.724 +           .
  12.725 +          <code title="dom-NavigatorNetworkServiceError-code">
  12.726 +            <a href="#dom-navigatornetworkserviceerror-code">code</a>
  12.727 +          </code>
  12.728 +        </dt>
  12.729 +        <dd>
  12.730 +          <p>
  12.731 +            Returns the current error's error code. At the current time, this may be <code>1</code> or <code>2</code>, for which the
  12.732 +            corresponding error constants
  12.733 +            <a href="#dom-navigatornetworkserviceerror-permission_denied"><code>PERMISSION_DENIED_ERR</code></a> and
  12.734 +            <a href="#dom-navigatornetworkserviceerror-unknown_type_prefix"><code>UNKNOWN_TYPE_PREFIX_ERR</code></a> are defined.
  12.735 +          </p>
  12.736 +        </dd>
  12.737 +      </dl>
  12.738 +
  12.739 +         <p>
  12.740 +            The <dfn id="dom-navigatornetworkserviceerror-code" title="dom-navigatornetworkserviceerror-code"><code>code</code></dfn> attribute of a
  12.741 +            <a href="#navigatornetworkserviceerror"><code>NavigatorNetworkServiceError</code></a> object <em title="must" class="rfc2119">must</em> return the code for the error, which will be one of the following:
  12.742 +         </p>
  12.743 +
  12.744 +         <dl>
  12.745 +            <dt>
  12.746 +               <dfn id="dom-navigatornetworkserviceerror-permission_denied" title="dom-navigatornetworkserviceerror-permission_denied"><code>PERMISSION_DENIED_ERR</code></dfn> (numeric value 1)
  12.747 +            </dt>
  12.748 +            <dd>
  12.749 +               The user denied the page permission to access any services.
  12.750 +            </dd>
  12.751 +            <dt>
  12.752 +               <dfn id="dom-navigatornetworkserviceerror-unknown_type_prefix" title="dom-navigatornetworkserviceerror-unknown_type_prefix"><code>UNKNOWN_TYPE_PREFIX_ERR</code></dfn> (numeric value 2)
  12.753 +            </dt>
  12.754 +            <dd>
  12.755 +               No <a class="internalDFN" href="#dfn-valid-service-type">valid service type</a> tokens were provided in the method invocation.
  12.756 +            </dd>
  12.757 +         </dl>
  12.758 +
  12.759 +      </section>
  12.760 +
  12.761 +      </section>
  12.762 +      <section id="obtaining-networked-services">
  12.763 +      <!--OddPage--><h2><span class="secno">5. </span>Obtaining networked services</h2>
  12.764 +
  12.765 +      <p>
  12.766 +         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.
  12.767 +      </p>
  12.768 +
  12.769 +<pre class="widl">[NoInterfaceObject]
  12.770 +interface <dfn id="networkservices">NetworkServices</dfn> {
  12.771 +  readonly attribute unsigned long    <a href="#dom-networkservices-length">length</a>;
  12.772 +  getter <a href="#networkservice">NetworkService</a> (unsigned long index);
  12.773 +  <a href="#networkservice">NetworkService</a>? <a href="#dom-networkservices-getservicebyid">getServiceById</a>(DOMString id);
  12.774 +
  12.775 +  readonly attribute unsigned long    <a href="#dom-networkservices-servicesavailable">servicesAvailable</a>;
  12.776 +
  12.777 +  // event handler attributes
  12.778 +           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>;
  12.779 +           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>;
  12.780 +
  12.781 +};
  12.782 +
  12.783 +<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>;
  12.784 +</pre>
  12.785 +
  12.786 +      <section id="attributes">
  12.787 +      <h3><span class="secno">5.1 </span>Attributes</h3>
  12.788 +
  12.789 +        <dl class="domintro">
  12.790 +          <dt>
  12.791 +            <code title="dom-networkservices-length">
  12.792 +              <a href="#dom-networkservices-length">length</a>
  12.793 +            </code>
  12.794 +          </dt>
  12.795 +          <dd>
  12.796 +            <p>
  12.797 +              Returns the current number of services in the respective object's <a class="internalDFN" href="#current_authorized_services">current authorized services</a>.
  12.798 +            </p>
  12.799 +          </dd>
  12.800 +          <dt>
  12.801 +            <code title="dom-networkservices-servicesavailable">
  12.802 +              <a href="#dom-networkservices-servicesavailable">servicesAvailable</a>
  12.803 +            </code>
  12.804 +          </dt>
  12.805 +          <dd>
  12.806 +            <p>
  12.807 +              Returns the current number of services matching one of the app-requested <a class="internalDFN" href="#dfn-valid-service-type">valid service type</a> tokens that are actively available within the user's current network.
  12.808 +            </p>
  12.809 +          </dd>
  12.810 +        </dl>
  12.811 +
  12.812 +        <div>
  12.813 +           <p>
  12.814 +              The <dfn id="dom-networkservices-length"><code>length</code></dfn> attribute <em title="must" class="rfc2119">must</em> return the number of services represented in the object's corresponding <a class="internalDFN" href="#current_authorized_services">current authorized services</a> list at the time of getting.
  12.815 +           </p>
  12.816 +
  12.817 +           <p>
  12.818 +              The <dfn id="dom-networkservices-servicesavailable"><code>servicesAvailable</code></dfn> attribute <em title="must" class="rfc2119">must</em> return the number of services available in the
  12.819 +              user's network that match the <a class="internalDFN" href="#dfn-valid-service-type">valid service type</a> that was initially used to create the current <a href="#networkservices"><code>NetworkServices</code></a> object.
  12.820 +              By default, <a href="#dom-networkservices-servicesavailable"><code>servicesAvailable</code></a> <em title="must" class="rfc2119">must</em> be set to <code>1</code>.
  12.821 +           </p>
  12.822 +
  12.823 +           <p>
  12.824 +             When a previously unknown instance of a networked service matching one or the requested <a href="#dfn-valid-service-type">valid service types</a> becomes available on the user's current network, the <a class="internalDFN" href="#dfn-user-agent">user agent</a> <em title="must" class="rfc2119">must</em> fire a new simple
  12.825 +             event at the <a href="#dom-networkservices-onserviceavailable"><code>onserviceavailable</code></a> event handler.
  12.826 +           </p>
  12.827 +
  12.828 +           <p>
  12.829 +             When a previously known instance of a networked service matching one or the requested <a href="#dfn-valid-service-type">valid service types</a> becomes unavailable on the user's current network, the <a class="internalDFN" href="#dfn-user-agent">user agent</a> <em title="must" class="rfc2119">must</em> fire a new simple
  12.830 +             event at the <a href="#dom-networkservices-onserviceunavailable"><code>onserviceunavailable</code></a> event handler.
  12.831 +           </p>
  12.832 +        </div>
  12.833 +
  12.834 +      </section>
  12.835 +
  12.836 +      <section id="methods-1">
  12.837 +      <h3><span class="secno">5.2 </span>Methods</h3>
  12.838 +        <dl class="domintro">
  12.839 +        <dt>
  12.840 +          <code title="networkservices-getter">
  12.841 +            <a href="#networkservices">services</a>
  12.842 +          </code>
  12.843 +          [
  12.844 +          <var title="">index</var>
  12.845 +          ]
  12.846 +        </dt>
  12.847 +        <dd>
  12.848 +          <p>
  12.849 +            Returns the specified <a href="#networkservice"><code>NetworkService</code></a> object.
  12.850 +          </p>
  12.851 +        </dd>
  12.852 +        <dt>
  12.853 +          <code title="networkservices-getter">
  12.854 +            <a href="#networkservices">services</a>
  12.855 +          </code>
  12.856 +          .
  12.857 +          <code title="dom-networkservices-getservicebyid">
  12.858 +            <a href="#dom-networkservices-getservicebyid">getServiceById</a>
  12.859 +          </code>
  12.860 +          (
  12.861 +          <var title="">id</var>
  12.862 +          )
  12.863 +        </dt>
  12.864 +        <dd>
  12.865 +          <p>
  12.866 +            Returns the <a href="#networkservice"><code>NetworkService</code></a> object with the given identifier, or null if no
  12.867 +            service has that identifier.
  12.868 +          </p>
  12.869 +        </dd>
  12.870 +      </dl>
  12.871 +
  12.872 +      <p>
  12.873 +        A <a href="#networkservices"><code>NetworkServices</code></a> object represents the current list of zero or more <a class="internalDFN" href="#current_authorized_services">current authorized services</a>, of which zero or more can be available at a time. Each item in <a class="internalDFN" href="#current_authorized_services">current authorized services</a> is represented by a <a href="#networkservice"><code>NetworkService</code></a> object.
  12.874 +      </p>
  12.875 +
  12.876 +      <div class="note"><div class="note-title"><span>Note</span></div><p class="">
  12.877 +        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. If the <a class="internalDFN" href="#dfn-user-agent">user agent</a> dynamically adds or removes network services for any reason, then the indices of the services in <a class="internalDFN" href="#current_authorized_services">current authorized services</a> will change dynamically. If the set of network services changes entirely, then all the previous services will be removed from <a class="internalDFN" href="#current_authorized_services">current authorized services</a> and replaced with new services.
  12.878 +      </p></div>
  12.879 +
  12.880 +      <p>
  12.881 +        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 <a class="internalDFN" href="#current_authorized_services">current authorized services</a> represented by the respective object minus one, if any services are represented in <a class="internalDFN" href="#current_authorized_services">current authorized services</a>. If a <a href="#networkservices"><code>NetworkServices</code></a> object represents no <a class="internalDFN" href="#current_authorized_services">current authorized services</a>, it has no <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/infrastructure.html#supported-property-indices" class="externalDFN">supported property indices</a>.
  12.882 +      </p>
  12.883 +
  12.884 +      <p>
  12.885 +        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 class="internalDFN" href="#current_authorized_services">current authorized services</a>, the user agent <em title="must" class="rfc2119">must</em> return the <a href="#networkservice"><code>NetworkService</code></a> object that represents the <var>index</var>th service in <a class="internalDFN" href="#current_authorized_services">current authorized services</a>.
  12.886 +      </p>
  12.887 +
  12.888 +      <p>
  12.889 +        The <dfn id="dom-networkservices-getservicebyid"><code>getServiceById(id)</code></dfn> method <em title="must" class="rfc2119">must</em> return the first <a href="#networkservice"><code>NetworkService</code></a> object in <a class="internalDFN" href="#current_authorized_services">current authorized services</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.
  12.890 +        When no services in <a class="internalDFN" href="#current_authorized_services">current authorized services</a> match the given argument, the method <em title="must" class="rfc2119">must</em> return null.
  12.891 +      </p>
  12.892 +
  12.893 +      <p>
  12.894 +         Services available within the local network can connect and disconnect at different times during the execution of a web page. A <a class="internalDFN" href="#dfn-user-agent">user agent</a> can
  12.895 +         inform a web page when the state of networked services matching the requested <a class="internalDFN" href="#dfn-valid-service-type">valid service type</a> change. Web pages can use this information to enable in-page experiences for communicating the state of networked services
  12.896 +         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.
  12.897 +      </p>
  12.898 +
  12.899 +      </section>
  12.900 +
  12.901 +      <section id="events">
  12.902 +      <h3><span class="secno">5.3 </span>Events</h3>
  12.903 +
  12.904 +      <p>
  12.905 +         The following are the event handlers (and their corresponding event handler event types) that must be supported, as IDL attributes, by all objects implementing the <a href="#networkservices"><code>NetworkServices</code></a> interface:
  12.906 +       </p>
  12.907 +
  12.908 +       <table border="1">
  12.909 +        <thead>
  12.910 +          <tr>
  12.911 +            <th>
  12.912 +              <span title="event handlers">Event handler</span>
  12.913 +            </th>
  12.914 +            <th>
  12.915 +              <span>Event handler event type</span>
  12.916 +            </th>
  12.917 +          </tr>
  12.918 +        </thead>
  12.919 +        <tbody>
  12.920 +          <tr>
  12.921 +            <td>
  12.922 +              <dfn id="dom-networkservices-onserviceavailable" title="dom-NetworkServices-onserviceavailable">
  12.923 +                <code>onserviceavailable</code>
  12.924 +              </dfn>
  12.925 +            </td>
  12.926 +            <td>
  12.927 +              <code title="event-serviceavailable">serviceavailable</code>
  12.928 +            </td>
  12.929 +          </tr>
  12.930 +          <tr>
  12.931 +            <td>
  12.932 +              <dfn id="dom-networkservices-onserviceunavailable" title="dom-NetworkServices-onserviceunavailable">
  12.933 +                <code>onserviceunavailable</code>
  12.934 +              </dfn>
  12.935 +            </td>
  12.936 +            <td>
  12.937 +              <code title="event-serviceunavailable">serviceunavailable</code>
  12.938 +            </td>
  12.939 +          </tr>
  12.940 +        </tbody>
  12.941 +      </table>
  12.942 +
  12.943 +      <p>
  12.944 +         Events with an event type of <code>serviceavailable</code> or <code>serviceunavailable</code> defined in this specification are simple <code>Event</code> objects.
  12.945 +      </p>
  12.946 +
  12.947 +      </section>
  12.948 +
  12.949 +    </section>
  12.950 +    <section id="communicating-with-a-networked-service">
  12.951 +    <!--OddPage--><h2><span class="secno">6. </span>Communicating with a networked service</h2>
  12.952 +
  12.953 +<p>
  12.954 +   The <a href="#networkservice"><code>NetworkService</code></a> interface is used to provide a set of connection information for an <abbr title="Hypertext Transfer Protocol">HTTP</abbr> service endpoint and if available, service events, running on a networked device.
  12.955 +</p>
  12.956 +
  12.957 +<pre class="widl">[NoInterfaceObject]
  12.958 +interface <dfn id="networkservice">NetworkService</dfn> {
  12.959 +  readonly attribute DOMString        <a href="#dom-networkservice-id">id</a>;
  12.960 +  readonly attribute DOMString        <a href="#dom-networkservice-name">name</a>;
  12.961 +  readonly attribute DOMString        <a href="#dom-networkservice-type">type</a>;
  12.962 +  readonly attribute DOMString        <a href="#dom-networkservice-url">url</a>;
  12.963 +  readonly attribute DOMString        <a href="#dom-networkservice-config">config</a>;
  12.964 +
  12.965 +  const unsigned short <a href="#dom-networkservice-AVAILABLE">AVAILABLE</a>      = 1;
  12.966 +  const unsigned short <a href="#dom-networkservice-UNAVAILABLE">UNAVAILABLE</a>    = 2;
  12.967 +  readonly attribute unsigned short   <a href="#dom-networkservice-readystate">readyState</a>;
  12.968 +
  12.969 +  // event handler attributes
  12.970 +           attribute <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/webappapis.html#eventhandler" class="externalDFN">EventHandler</a>     <a href="#dom-networkservice-onreadystatechange">onreadystatechange</a>;
  12.971 +           attribute <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/webappapis.html#eventhandler" class="externalDFN">EventHandler</a>     <a href="#dom-networkservice-onmessage">onmessage</a>;
  12.972 +};
  12.973 +
  12.974 +<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>;
  12.975 +</pre>
  12.976 +
  12.977 +<section id="attributes-1">
  12.978 +  <h3><span class="secno">6.1 </span>Attributes</h3>
  12.979 +
  12.980 +      <dl class="domintro">
  12.981 +        <dt>
  12.982 +          <var title="">service</var>
  12.983 +           .
  12.984 +          <code title="dom-networkservice-id">
  12.985 +            <a href="#dom-networkservice-id">id</a>
  12.986 +          </code>
  12.987 +        </dt>
  12.988 +        <dd>
  12.989 +          <p>
  12.990 +            A unique identifier for the given user-selected service instance.
  12.991 +          </p>
  12.992 +        </dd>
  12.993 +        <dt>
  12.994 +          <var title="">service</var>
  12.995 +           .
  12.996 +          <code title="dom-networkservice-name">
  12.997 +            <a href="#dom-networkservice-name">name</a>
  12.998 +          </code>
  12.999 +        </dt>
 12.1000 +        <dd>
 12.1001 +          <p>
 12.1002 +            The name of the user-selected service.
 12.1003 +          </p>
 12.1004 +        </dd>
 12.1005 +        <dt>
 12.1006 +          <var title="">service</var>
 12.1007 +           .
 12.1008 +          <code title="dom-networkservice-type">
 12.1009 +            <a href="#dom-networkservice-type">type</a>
 12.1010 +          </code>
 12.1011 +        </dt>
 12.1012 +        <dd>
 12.1013 +          <p>
 12.1014 +            The <a class="internalDFN" href="#dfn-valid-service-type">valid service type</a> token value of the user-selected service.
 12.1015 +          </p>
 12.1016 +        </dd>
 12.1017 +        <dt>
 12.1018 +          <var title="">service</var>
 12.1019 +           .
 12.1020 +          <code title="dom-networkservice-url">
 12.1021 +            <a href="#dom-networkservice-url">url</a>
 12.1022 +          </code>
 12.1023 +        </dt>
 12.1024 +        <dd>
 12.1025 +          <p>
 12.1026 +            The control <abbr title="Uniform Resource Locator">URL</abbr> endpoint (including any required port information) of the user-selected control service that has been added to the <a class="internalDFN" href="#dfn-entry-script-origin-s-url-whitelist">entry script origin's <abbr title="Uniform Resource Locator">URL</abbr> whitelist</a>.
 12.1027 +          </p>
 12.1028 +        </dd>
 12.1029 +        <dt>
 12.1030 +          <var title="">service</var>
 12.1031 +           .
 12.1032 +          <code title="dom-networkservice-config">
 12.1033 +            <a href="#dom-networkservice-config">config</a>
 12.1034 +          </code>
 12.1035 +        </dt>
 12.1036 +        <dd>
 12.1037 +          <p>
 12.1038 +            The configuration information associated with the service depending on the requested service type.
 12.1039 +          </p>
 12.1040 +        </dd>
 12.1041 +      </dl>
 12.1042 +
 12.1043 +          <p>
 12.1044 +            The <dfn id="dom-networkservice-id"><code>id</code></dfn> attribute is a unique identifier for the service. Two services provided at different times or on different objects <em title="must" class="rfc2119">must</em> have the same <a href="#dom-networkservice-id"><code>id</code></a> value.
 12.1045 +         </p>
 12.1046 +
 12.1047 +         <p>
 12.1048 +            The <dfn id="dom-networkservice-name"><code>name</code></dfn> attribute represents a human-readable title for the service.
 12.1049 +         </p>
 12.1050 +
 12.1051 +         <p>
 12.1052 +             The <dfn id="dom-networkservice-type"><code>type</code></dfn> attribute reflects the value of the <a class="internalDFN" href="#dfn-valid-service-type">valid service type</a> of the service.
 12.1053 +          </p>
 12.1054 +
 12.1055 +         <p>
 12.1056 +            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 <abbr title="Uniform Resource Locator">URL</abbr></a> pointing to the root <abbr title="Hypertext Transfer Protocol">HTTP</abbr>
 12.1057 +            endpoint for the service that has been added to the <a class="internalDFN" href="#dfn-entry-script-origin-s-url-whitelist">entry script origin's <abbr title="Uniform Resource Locator">URL</abbr> 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).
 12.1058 +         </p>
 12.1059 +
 12.1060 +         <p>
 12.1061 +            The <dfn id="dom-networkservice-config"><code>config</code></dfn> attribute provides the raw configuration information extracted from the given network service.
 12.1062 +         </p>
 12.1063 +
 12.1064 +      </section>
 12.1065 +
 12.1066 +      <section id="states">
 12.1067 +         <h3><span class="secno">6.2 </span>States</h3>
 12.1068 +
 12.1069 +      <dl class="domintro">
 12.1070 +        <dt>
 12.1071 +          <var title="">service</var>
 12.1072 +           .
 12.1073 +          <code title="dom-networkservice-readystate">
 12.1074 +            <a href="#dom-networkservice-readystate">readyState</a>
 12.1075 +          </code>
 12.1076 +        </dt>
 12.1077 +        <dd>
 12.1078 +          <p>
 12.1079 +            Returns the current state.
 12.1080 +          </p>
 12.1081 +        </dd>
 12.1082 +      </dl>
 12.1083 +
 12.1084 +         A <a href="#networkservice"><code>NetworkService</code></a> object can be in several states. The <dfn id="dom-networkservice-readystate"><code>readyState</code></dfn> attribute <em title="must" class="rfc2119">must</em> return the current state of the networked service,
 12.1085 +         which <em title="must" class="rfc2119">must</em> be one of the following values:
 12.1086 +
 12.1087 +         <dl>
 12.1088 +           <dt>
 12.1089 +             <dfn id="dom-networkservice-AVAILABLE" title="dom-networkservice-AVAILABLE">
 12.1090 +               <code>AVAILABLE</code>
 12.1091 +             </dfn>
 12.1092 +              (numeric value
 12.1093 +             1)
 12.1094 +
 12.1095 +
 12.1096 +           </dt>
 12.1097 +           <dd>
 12.1098 +             <p>The object is connected to its service endpoint.
 12.1099 +
 12.1100 +            </p>
 12.1101 +           </dd>
 12.1102 +           <dt>
 12.1103 +             <dfn id="dom-networkservice-UNAVAILABLE" title="dom-networkservice-UNAVAILABLE">
 12.1104 +               <code>UNAVAILABLE</code>
 12.1105 +             </dfn>
 12.1106 +              (numeric value
 12.1107 +             2)
 12.1108 +           </dt>
 12.1109 +           <dd>
 12.1110 +             <p>The object is not connected to its service endpoint.
 12.1111 +            </p>
 12.1112 +           </dd>
 12.1113 +         </dl>
 12.1114 +
 12.1115 +      </section>
 12.1116 +
 12.1117 +      <section id="events-1">
 12.1118 +         <h3><span class="secno">6.3 </span>Events</h3>
 12.1119 +
 12.1120 +      <p>
 12.1121 +         The following are the event handlers (and their corresponding event handler event types) that must be supported, as IDL attributes, by all objects implementing the
 12.1122 +         <a href="#networkservice"><code>NetworkService</code></a> interface:
 12.1123 +       </p>
 12.1124 +
 12.1125 +       <table border="1">
 12.1126 +        <thead>
 12.1127 +          <tr>
 12.1128 +            <th>
 12.1129 +              <span title="event handlers">Event handler</span>
 12.1130 +            </th>
 12.1131 +            <th>
 12.1132 +              <span>Event handler event type</span>
 12.1133 +            </th>
 12.1134 +          </tr>
 12.1135 +        </thead>
 12.1136 +        <tbody>
 12.1137 +          <tr>
 12.1138 +            <td>
 12.1139 +              <dfn id="dom-networkservice-onmessage" title="dom-NetworkService-onmessage">
 12.1140 +                <code>onmessage</code>
 12.1141 +              </dfn>
 12.1142 +            </td>
 12.1143 +            <td>
 12.1144 +              <code title="event-message">message</code>
 12.1145 +            </td>
 12.1146 +          </tr>
 12.1147 +          <tr>
 12.1148 +            <td>
 12.1149 +              <dfn id="dom-networkservice-onreadystatechange" title="dom-NetworkService-onreadystatechange">
 12.1150 +                <code>onreadystatechange</code>
 12.1151 +              </dfn>
 12.1152 +            </td>
 12.1153 +            <td>
 12.1154 +              <code title="event-onreadystatechange">readystatechange</code>
 12.1155 +            </td>
 12.1156 +          </tr>
 12.1157 +        </tbody>
 12.1158 +      </table>
 12.1159 +
 12.1160 +      <p>
 12.1161 +         Events with an event type of <code>message</code> defined in this specification are <a href="http://dev.w3.org/html5/postmsg/#messageevent" class="externalDFN"><code>MessageEvent</code></a> objects as defined in [<cite><a href="#bib-POSTMSG" class="bibref">POSTMSG</a></cite>].
 12.1162 +      </p>
 12.1163 +
 12.1164 +      <p>
 12.1165 +         Events with an event type of <code>readystatechange</code> defined in this specification are simple <code>Event</code> objects.
 12.1166 +      </p>
 12.1167 +
 12.1168 +      </section>
 12.1169 +   </section>
 12.1170 +
 12.1171 +      <section id="service-discovery">
 12.1172 +            <!--OddPage--><h2><span class="secno">7. </span>Service Discovery</h2>
 12.1173 +
 12.1174 +      <p>
 12.1175 +         A <a class="internalDFN" href="#dfn-user-agent">user agent</a> conforming to this specification <em title="may" class="rfc2119">may</em> implement <abbr title="Simple Service Discovery Protocol">SSDP</abbr> [<cite><a href="#bib-UPNP-DEVICEARCH11" class="bibref">UPNP-DEVICEARCH11</a></cite>] and Zeroconf [<cite><a href="#bib-ZEROCONF" class="bibref">ZEROCONF</a></cite>] service discovery mechanisms
 12.1176 +         to enable Web pages to request and connect with <abbr title="Hypertext Transfer Protocol">HTTP</abbr> services running on networked devices, discovered via either mechanism, through this <abbr title="Application Programming Interface">API</abbr>. When a <a class="internalDFN" href="#dfn-user-agent">user agent</a> implements either of these service discovery mechanisms, then it <em title="must" class="rfc2119">must</em> conform to the corresponding algorithms provided in this section of the specification.
 12.1177 +      </p>
 12.1178 +      <p>
 12.1179 +         This section presents how the results of these two service discovery
 12.1180 +         mechanisms will be matched to requested service types and how their properties will be applied to any resulting <a href="#networkservice"><code>NetworkService</code></a> objects.
 12.1181 +      </p>
 12.1182 +
 12.1183 +      <p>
 12.1184 +         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
 12.1185 +         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
 12.1186 +         invocation of this <abbr title="Application Programming Interface">API</abbr> from a Web page).
 12.1187 +      </p>
 12.1188 +
 12.1189 +      <p>
 12.1190 +         The <dfn id="dfn-list-of-available-service-records">list of available service records</dfn> is a single dynamic internal lookup table within user agents that is used to track the current services available in the network at any given time.
 12.1191 +         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
 12.1192 +         services changes. Each record contained within this table contains the attributes: <code>id</code>, <code>name</code>, <code>type</code>, <code>url</code> and <code>config</code>.
 12.1193 +      </p>
 12.1194 +
 12.1195 +            <section id="zeroconf-mdns-dns-sd">
 12.1196 +         <h3><span class="secno">7.1 </span>Zeroconf (<abbr title="Multicast DNS">mDNS</abbr> + <abbr title="Domain Name System">DNS</abbr>-<abbr title="Service Discovery">SD</abbr>)</h3>
 12.1197 +
 12.1198 +         <p>
 12.1199 +            For each <abbr title="Domain Name System">DNS</abbr> response received from a user-agent-initiated Multicast <abbr title="Domain Name System">DNS</abbr> 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
 12.1200 +   domain [<cite><a href="#bib-MDNS" class="bibref">MDNS</a></cite>], the <a class="internalDFN" href="#dfn-user-agent">user agent</a> <em title="must" class="rfc2119">must</em> run the following steps:
 12.1201 +         </p>
 12.1202 +
 12.1203 +         <ol class="rule">
 12.1204 +
 12.1205 +            <li>Let <var>service <abbr title="Multicast DNS">mDNS</abbr> responses</var> be an array of <abbr title="DNS Pointer Record">PTR</abbr> records received by issuing a Multicast <abbr title="Domain Name System">DNS</abbr> Browse for <abbr title="DNS Pointer Record">PTR</abbr> records with the name of the current discovered service type.</li>
 12.1206 +
 12.1207 +            <li>For each Object <var>service <abbr title="Multicast DNS">mDNS</abbr> response</var> in <var>service <abbr title="Multicast DNS">mDNS</abbr> responses</var>, run the following steps:
 12.1208 +               <ol>
 12.1209 +
 12.1210 +                  <li>
 12.1211 +                     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>.
 12.1212 +                  </li>
 12.1213 +
 12.1214 +                  <li>
 12.1215 +                     Set <var>network service record</var>'s <code>id</code> property to the value of the full <abbr title="DNS Pointer Record">PTR</abbr> Service Instance Name [<cite><a href="#bib-MDNS" class="bibref">MDNS</a></cite>].
 12.1216 +                  </li>
 12.1217 +
 12.1218 +                  <li>
 12.1219 +                     Set <var>network service record</var>'s <code>name</code> property to the value of the <abbr title="DNS Pointer Record">PTR</abbr> Service Instance Name's <var>Instance</var> component [<cite><a href="#bib-MDNS" class="bibref">MDNS</a></cite>].
 12.1220 +                  </li>
 12.1221 +
 12.1222 +                  <li>
 12.1223 +                     Set <var>network service record</var>'s <code>type</code> property to the concatenation of the string <code>zeroconf:</code> followed by the value of the <abbr title="DNS Pointer Record">PTR</abbr> Service Instance Name's <var>Service</var> component [<cite><a href="#bib-MDNS" class="bibref">MDNS</a></cite>].
 12.1224 +                  </li>
 12.1225 +
 12.1226 +                  <li>
 12.1227 +                     Set <var>network service record</var>'s <code>url</code> property to the resolvable Service <abbr title="Uniform Resource Locator">URL</abbr> obtained from performing an <abbr title="Domain Name System">DNS</abbr>-<abbr title="Service Discovery">SD</abbr> Lookup [<cite><a href="#bib-DNS-SD" class="bibref">DNS-SD</a></cite>] of the current service from the <abbr title="DNS Pointer Record">PTR</abbr> record provided [<cite><a href="#bib-MDNS" class="bibref">MDNS</a></cite>].
 12.1228 +                  </li>
 12.1229 +
 12.1230 +                  <li>
 12.1231 +                     Set <var>network service record</var>'s <code>config</code> property to the string value of the contents of the first <abbr title="Domain Name System">DNS</abbr>-<abbr title="Service Discovery">SD</abbr> TXT record associated with the <var>service <abbr title="Multicast DNS">mDNS</abbr> response</var> as defined in [<cite><a href="#bib-DNS-SD" class="bibref">DNS-SD</a></cite>].
 12.1232 +                  </li>
 12.1233 +
 12.1234 +                  <li>
 12.1235 +                     For each Object <var>existing service record</var> in the current <a class="internalDFN" href="#dfn-list-of-available-service-records">list of available service records</a>, run the following sub-steps:
 12.1236 +                     <ol class="rule">
 12.1237 +
 12.1238 +                       <li>
 12.1239 +                        If the <var>existing service record</var>'s <code>id</code> property matches the value of the <var>network service record</var>'s <code>id</code>, then set the
 12.1240 +                        value of <var>existing service record</var> in the current <a class="internalDFN" href="#dfn-list-of-available-service-records">list of available service records</a>  to the value of the
 12.1241 +                        <var>network service record</var> and skip the next step.
 12.1242 +                       </li>
 12.1243 +                     </ol>
 12.1244 +                  </li>
 12.1245 +
 12.1246 +                  <li>
 12.1247 +                     Add <var>network service record</var> to the <a class="internalDFN" href="#dfn-list-of-available-service-records">list of available service records</a>.
 12.1248 +                  </li>
 12.1249 +
 12.1250 +                  <li>
 12.1251 +                     For each non-garbage collected <a href="#networkservice"><code>NetworkService</code></a> object run the following steps:
 12.1252 +
 12.1253 +                     <ol class="rule">
 12.1254 +                        <li>
 12.1255 +                           If the <a href="#networkservice"><code>NetworkService</code></a> object's <code>type</code> attribute does not equal the
 12.1256 +                           current <a>network service record</a>'s <code>type</code> property then continue at the next available active
 12.1257 +                           <a href="#networkservice"><code>NetworkService</code></a> object.
 12.1258 +                        </li>
 12.1259 +                        <li>
 12.1260 +                           Increment the <code>servicesAvailable</code> attribute of the <a href="#networkservices"><code>NetworkServices</code></a> object by <code>1</code>.
 12.1261 +                        </li>
 12.1262 +                     </ol>
 12.1263 +                  </li>
 12.1264 +            </ol>
 12.1265 +           </li>
 12.1266 +         </ol>
 12.1267 +
 12.1268 +      </section>
 12.1269 +
 12.1270 +      <section id="universal-plug-and-play-upnp">
 12.1271 +         <h3><span class="secno">7.2 </span>Universal Plug-and-Play (<abbr title="Universal Plug-and-Play">UPnP</abbr>)</h3>
 12.1272 +
 12.1273 +         <p>
 12.1274 +            For each <abbr title="Simple Service Discovery Protocol">SSDP</abbr> Presence Announcement [<cite><a href="#bib-UPNP-DEVICEARCH11" class="bibref">UPNP-DEVICEARCH11</a></cite>] - a <abbr title="Hypertext Transfer Protocol">HTTP</abbr> NOTIFY request - received from a user-agent-initiated <abbr title="Simple Service Discovery Protocol">SSDP</abbr> Discovery Request [<cite><a href="#bib-UPNP-DEVICEARCH11" class="bibref">UPNP-DEVICEARCH11</a></cite>], the <a class="internalDFN" href="#dfn-user-agent">user agent</a> <em title="must" class="rfc2119">must</em> run the following steps:
 12.1275 +         </p>
 12.1276 +
 12.1277 +         <ol class="rule">
 12.1278 +            <li>
 12.1279 +               Let <var>ssdp device</var> be an Object with a property for each <abbr title="Hypertext Transfer Protocol">HTTP</abbr> header received in the received <abbr title="Simple Service Discovery Protocol">SSDP</abbr> Presence Announcement, with each key being the name of a <abbr title="Hypertext Transfer Protocol">HTTP</abbr> header and its
 12.1280 +               value being that <abbr title="Hypertext Transfer Protocol">HTTP</abbr> header's accompanying value.
 12.1281 +            </li>
 12.1282 +
 12.1283 +            <li>
 12.1284 +               If <var>ssdp device</var> does not contain at least one <var>NTS</var>, <var>USN</var> and <var>Location</var> parameter, then the <a class="internalDFN" href="#dfn-user-agent">user agent</a> <em title="must" class="rfc2119">must</em> abort these steps.
 12.1285 +            </li>
 12.1286 +
 12.1287 +            <li>
 12.1288 +               If the first occurrence of <var>NTS</var> has a value other than <code>ssdp:alive</code>, then continue to the step labeled <var>update service monitor</var> below.
 12.1289 +            </li>
 12.1290 +
 12.1291 +            <li>
 12.1292 +               Let <var>root device descriptor file</var> contain the contents of the file located at the <abbr title="Uniform Resource Locator">URL</abbr> provided in the first occurrence of <var>Location</var> obtained according to the rules
 12.1293 +               defined in the section 'Retrieving a description using <abbr title="Hypertext Transfer Protocol">HTTP</abbr>' [<cite><a href="#bib-UPNP-DEVICEARCH11" class="bibref">UPNP-DEVICEARCH11</a></cite>].
 12.1294 +            </li>
 12.1295 +
 12.1296 +            <li>
 12.1297 +               If <var>root device descriptor file</var> is empty, then the <a class="internalDFN" href="#dfn-user-agent">user agent</a> <em title="must" class="rfc2119">must</em> abort these steps.
 12.1298 +            </li>
 12.1299 +
 12.1300 +            <li>
 12.1301 +               Let <var>advertised services</var> be a <a>list of all advertised services</a> obtained from the <var>root device descriptor file</var> containing all sub-nodes of the <code>serviceList</code> node as described in
 12.1302 +               the section 'Device Description' [<cite><a href="#bib-UPNP-DEVICEARCH11" class="bibref">UPNP-DEVICEARCH11</a></cite>].
 12.1303 +            </li>
 12.1304 +
 12.1305 +            <li>
 12.1306 +               For each Object <var>advertised service</var> in <var>advertised services</var> run the following steps:
 12.1307 +               <ol class="rule">
 12.1308 +
 12.1309 +                  <li>
 12.1310 +                     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>eventsUrl</code>, <code>config</code>.
 12.1311 +                  </li>
 12.1312 +
 12.1313 +                  <li>
 12.1314 +                     Set <var>network service record</var>'s <code>id</code> property to the string value of the first occurrence of <var>ssdp device</var>'s <var>USN</var> parameter.
 12.1315 +                  </li>
 12.1316 +
 12.1317 +                  <li>
 12.1318 +                     Set <var>network service record</var>'s <code>name</code> property to the string value of the first occurrence of the <var>service</var>'s <code>serviceId</code> property.
 12.1319 +                  </li>
 12.1320 +
 12.1321 +                  <li>
 12.1322 +                     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>service</var>'s <code>serviceType</code> property.
 12.1323 +                  </li>
 12.1324 +
 12.1325 +                  <li>
 12.1326 +                     Set <var>network service record</var>'s <code>url</code> property to the string value of the first occurrence of the <var>service</var>'s <code>controlURL</code> property.
 12.1327 +                  </li>
 12.1328 +
 12.1329 +                  <li>
 12.1330 +                     Set <var>network service record</var>'s <code>config</code> property to the string value of the first occurrence of the <var>device</var> property.
 12.1331 +                  </li>
 12.1332 +
 12.1333 +                  <li>
 12.1334 +                     If <var>service</var>'s <code>eventSubURL</code> property is empty, then continue to the step labeled <em>register</em> below.
 12.1335 +                  </li>
 12.1336 +
 12.1337 +                  <li>
 12.1338 +                     Set <var>network service record</var>'s <code>eventsUrl</code> property to the string value of the first occurrence of the <var>service</var>'s <code>eventSubURL</code> property.
 12.1339 +                  </li>
 12.1340 +
 12.1341 +                  <li>
 12.1342 +                     <em>Register</em>: For each Object <var>existing service record</var> in the current <a class="internalDFN" href="#dfn-list-of-available-service-records">list of available service records</a>, run the following sub-steps:
 12.1343 +                     <ol class="rule">
 12.1344 +
 12.1345 +                       <li>
 12.1346 +                        If the <var>existing service record</var>'s <var>id</var> property matches the value of the first occurrence of <var>USN</var> and the
 12.1347 +                        <var>existing service record</var>'s <code>type</code> property matches the value of <var>network service record</var>'s <code>type</code>, then set the
 12.1348 +                        value of <var>existing service record</var> in the current <a class="internalDFN" href="#dfn-list-of-available-service-records">list of available service records</a>  to the value of the
 12.1349 +                        <var>network service record</var> and skip the next step.
 12.1350 +                       </li>
 12.1351 +                     </ol>
 12.1352 +                  </li>
 12.1353 +
 12.1354 +                  <li>
 12.1355 +                     Add <var>network service record</var> to the <a class="internalDFN" href="#dfn-list-of-available-service-records">list of available service records</a>.
 12.1356 +                  </li>
 12.1357 +
 12.1358 +               </ol>
 12.1359 +            </li>
 12.1360 +            <li>
 12.1361 +               <em>Update Service Monitor</em>: For each non-garbage collected <a href="#networkservice"><code>NetworkService</code></a> object run the following steps:
 12.1362 +
 12.1363 +               <ol class="rule">
 12.1364 +                  <li>
 12.1365 +                     If this <a href="#networkservice"><code>NetworkService</code></a> object's <code>type</code> attribute does not equal the
 12.1366 +                     current <a>network service record</a>'s <code>type</code> property then continue at the next available active
 12.1367 +                     <a href="#networkservice"><code>NetworkService</code></a> object.
 12.1368 +                  </li>
 12.1369 +                  <li>
 12.1370 +                     If the <var>announcement type</var> equals <code>ssdp:alive</code> then Increment the <code>servicesAvailable</code> attribute of the <a href="#networkservices"><code>NetworkServices</code></a>
 12.1371 +                     object by <code>1</code>. Otherwise, decrement the <code>servicesAvailable</code> attribute of the <a href="#networkservices"><code>NetworkServices</code></a>
 12.1372 +                     object by <code>1</code>.
 12.1373 +                  </li>
 12.1374 +               </ol>
 12.1375 +            </li>
 12.1376 +         </ol>
 12.1377 +
 12.1378 +         <p>
 12.1379 +            A <dfn id="dfn-user-agent-generated-callback-url">user-agent generated callback url</dfn> is a Local-network accessible <abbr title="Uniform Resource Locator">URL</abbr> endpoint that a <a class="internalDFN" href="#dfn-user-agent">user agent</a> must generate and maintain for receiving <abbr title="Hypertext Transfer Protocol">HTTP</abbr> NOTIFY requests from <abbr title="Universal Plug-and-Play">UPnP</abbr> Event sources.
 12.1380 +         </p>
 12.1381 +
 12.1382 +         <p>When the <a class="internalDFN" href="#dfn-user-agent">user agent</a> is to <dfn id="dfn-setup-a-upnp-events-subscription">setup a <abbr title="Universal Plug-and-Play">UPnP</abbr> Events Subscription</dfn>, it is to run the following steps with the current <var>network service record</var> object:</p>
 12.1383 +
 12.1384 +         <ol class="rule">
 12.1385 +            <li>
 12.1386 +               If <var>network service record</var>'s <code>eventsUrl</code> property is empty then the <a class="internalDFN" href="#dfn-user-agent">user agent</a> <em title="must" class="rfc2119">must</em> abort these steps.
 12.1387 +            </li>
 12.1388 +
 12.1389 +            <li>
 12.1390 +               Let <var>callback <abbr title="Uniform Resource Locator">URL</abbr></var> be the value of creating a new <a class="internalDFN" href="#dfn-user-agent-generated-callback-url">user-agent generated callback url</a>.
 12.1391 +            </li>
 12.1392 +
 12.1393 +            <li>
 12.1394 +               Send a <abbr title="Hypertext Transfer Protocol">HTTP</abbr> SUBSCRIBE request with a <em>NT</em> header with a string value of <code>upnp:event</code>, a <em>TIMEOUT</em> header with an integer value of
 12.1395 +               <code>86400</code> and a <em>CALLBACK</em> header
 12.1396 +               with a string value of <var>callback <abbr title="Uniform Resource Locator">URL</abbr></var> towards the <var>network service record</var>'s <code>eventsUrl</code> property.
 12.1397 +            </li>
 12.1398 +
 12.1399 +            <li>
 12.1400 +               If a non-200 OK response is received from the <abbr title="Hypertext Transfer Protocol">HTTP</abbr> SUBSCRIBE request then the <a class="internalDFN" href="#dfn-user-agent">user agent</a> <em title="must" class="rfc2119">must</em> abort these steps.
 12.1401 +            </li>
 12.1402 +
 12.1403 +            <li>
 12.1404 +               On receiving a valid 200 OK response, run the following steps:
 12.1405 +
 12.1406 +               <ol class="rule">
 12.1407 +                  <li>
 12.1408 +                     Let <var>callback ID</var> equal the string value of the first included <em>SID</em> header, if it exists.
 12.1409 +                  </li>
 12.1410 +                  <li>
 12.1411 +                     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, if it exists.
 12.1412 +                  </li>
 12.1413 +                  <li>
 12.1414 +                     Run the following steps aynchronously and continue to the step labeled <em>listen</em> below.
 12.1415 +                  </li>
 12.1416 +                  <li>
 12.1417 +                     <em>Refresh Subscription</em>: Run the following steps at a set interval (X) within the <a class="internalDFN" href="#dfn-user-agent">user agent</a>:
 12.1418 +
 12.1419 +                     <ol class="rule">
 12.1420 +                        <li>
 12.1421 +                           Let <var>current date</var> equal the current UTC date.
 12.1422 +                        </li>
 12.1423 +                        <li>
 12.1424 +                           If <var>current date</var> is less than the <var>timeout date</var> then continue to the step labeled <em>refresh subscription</em> above.
 12.1425 +                        </li>
 12.1426 +                        <li>
 12.1427 +                           Send a <abbr title="Hypertext Transfer Protocol">HTTP</abbr> SUBSCRIBE request with a <em>SID</em> header with the string value of <var>callback ID</var> and a <em>TIMEOUT</em> header
 12.1428 +                           with an integer value of <code>86400</code> towards the <var>network service record</var>'s <code>eventsUrl</code> property.
 12.1429 +                        </li>
 12.1430 +                        <li>
 12.1431 +                           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 <abbr title="Hypertext Transfer Protocol">HTTP</abbr>
 12.1432 +                           responses should cause the <a class="internalDFN" href="#dfn-user-agent">user agent</a> to continue from the step labeled <em>refresh subscription</em> above.
 12.1433 +                        </li>
 12.1434 +                     </ol>
 12.1435 +
 12.1436 +                  </li>
 12.1437 +
 12.1438 +                  <li>
 12.1439 +                     <em>Listen</em>: For each <abbr title="Hypertext Transfer Protocol">HTTP</abbr> NOTIFY request received at the <var>callback <abbr title="Uniform Resource Locator">URL</abbr></var> the <a class="internalDFN" href="#dfn-user-agent">user agent</a> is to run the following steps:
 12.1440 +
 12.1441 +                     <ol class="rule">
 12.1442 +                        <li>
 12.1443 +                           Let <var>content clone</var> be the result of obtaining the message body of the <abbr title="Hypertext Transfer Protocol">HTTP</abbr> NOTIFY request. If <var>content clone</var> is empty, then the <a class="internalDFN" href="#dfn-user-agent">user agent</a> <em title="must" class="rfc2119">must</em> abort these steps.
 12.1444 +                        </li>
 12.1445 +                        <li>
 12.1446 +                          Create a new <code>message</code> event that uses the <a href="http://dev.w3.org/html5/postmsg/#messageevent" class="externalDFN"><code>MessageEvent</code></a> interface [<cite><a href="#bib-POSTMSG" class="bibref">POSTMSG</a></cite>], with the name <code>message</code>,
 12.1447 +                           which does not bubble, is not cancelable, and has no default action.
 12.1448 +                        </li>
 12.1449 +                        <li>
 12.1450 +                           Let the <code>data</code> attribute of the event have the DOMString value of <var>content clone</var>.
 12.1451 +                        </li>
 12.1452 +                        <li>
 12.1453 +                           <a href="http://www.whatwg.org/specs/web-apps/current-work/complete/webappapis.html#queue-a-task" class="externalDFN">Queue a task</a> to
 12.1454 +                            dispatch the newly created event at the current <a class="internalDFN" href="#networkservice"><code>NetworkService</code></a> object.
 12.1455 +                        </li>
 12.1456 +                     </ol>
 12.1457 +                  </li>
 12.1458 +
 12.1459 +               </ol>
 12.1460 +
 12.1461 +            </li>
 12.1462 +         </ol>
 12.1463 +
 12.1464 +         </section>
 12.1465 +
 12.1466 +         <section id="network-topology-monitoring">
 12.1467 +            <h3><span class="secno">7.3 </span>Network Topology Monitoring</h3>
 12.1468 +
 12.1469 +                  <div>
 12.1470 +                     <p>
 12.1471 +                        When the <a class="internalDFN" href="#dfn-user-agent">user agent</a> detects that the user has dropped from their connected network, then it <em title="must" class="rfc2119">must</em> run the following steps:
 12.1472 +                     </p>
 12.1473 +
 12.1474 +                     <ol class="rule">
 12.1475 +                        <li>
 12.1476 +                           Flush all entries from the <a class="internalDFN" href="#dfn-list-of-available-service-records">list of available service records</a>.
 12.1477 +                        </li>
 12.1478 +                        <li>
 12.1479 +                           For each <a href="#networkservice"><code>NetworkService</code></a> object currently active in the <a class="internalDFN" href="#dfn-user-agent">user agent</a> perform the following steps:
 12.1480 +
 12.1481 +                           <ol class="rule">
 12.1482 +                              <li>
 12.1483 +                                 Set the <a href="#dom-networkservice-readystate"><code>readyState</code></a> attribute to <code>2</code> (<a href="#dom-networkservice-UNAVAILABLE"><code>UNAVAILABLE</code></a>).
 12.1484 +                              </li>
 12.1485 +                              <li>
 12.1486 +                                 Create a new <code>readystatechange</code> event that uses the <code>Event</code> interface which does not bubble, is not cancelable, and has no default action.
 12.1487 +                              </li>
 12.1488 +                              <li>
 12.1489 +                                 <a href="http://www.whatwg.org/specs/web-apps/current-work/complete/webappapis.html#queue-a-task" class="externalDFN">Queue a task</a> to
 12.1490 +                                        dispatch the newly created event at the <a href="#networkservice"><code>NetworkService</code></a> object.
 12.1491 +                              </li>
 12.1492 +                           </ol>
 12.1493 +                        </li>
 12.1494 +                     </ol>
 12.1495 +
 12.1496 +                     <p>
 12.1497 +                        When the <a class="internalDFN" href="#dfn-user-agent">user agent</a> detects that the user has connected to a new network, then it <em title="should" class="rfc2119">should</em> run the following steps:
 12.1498 +                     </p>
 12.1499 +
 12.1500 +                     <ol class="rule">
 12.1501 +                        <li>
 12.1502 +                           Re-issue an <abbr title="Multicast DNS">mDNS</abbr> search and <abbr title="Simple Service Discovery Protocol">SSDP</abbr> discovery search and handle the responses according to the processing defined in <a href="#service-discovery">Section 6: Service Discovery</a>.
 12.1503 +                        </li>
 12.1504 +                     </ol>
 12.1505 +                  </div>
 12.1506 +         </section>
 12.1507 +      </section>
 12.1508 +
 12.1509 +   <section id="garbage-collection">
 12.1510 +      <!--OddPage--><h2><span class="secno">8. </span>Garbage collection</h2>
 12.1511 +
 12.1512 +      <p>
 12.1513 +         A <a class="internalDFN" href="#networkservice"><code>NetworkService</code></a> object containing a <code>url</code> parameter currently in the <a class="internalDFN" href="#dfn-entry-script-origin-s-url-whitelist">entry script origin's <abbr title="Uniform Resource Locator">URL</abbr> whitelist</a> <em title="must not" class="rfc2119">must not</em> be garbage collected.
 12.1514 +      </p>
 12.1515 +
 12.1516 +      <p>
 12.1517 +         Only when the user navigates away from the current browsing context can <a class="internalDFN" href="#networkservice"><code>NetworkService</code></a> objects be garbage-collected and records in the <a class="internalDFN" href="#dfn-entry-script-origin-s-url-whitelist">entry script origin's <abbr title="Uniform Resource Locator">URL</abbr> whitelist</a> be removed.
 12.1518 +      </p>
 12.1519 +
 12.1520 +   </section>
 12.1521 +
 12.1522 +
 12.1523 +    <section id="use-cases-and-requirements">
 12.1524 +      <!--OddPage--><h2><span class="secno">9. </span>Use Cases and Requirements</h2>
 12.1525 +
 12.1526 +      <p>This section covers what the requirements are for this <abbr title="Application Programming Interface">API</abbr>, as well as illustrates some use cases.</p>
 12.1527 +
 12.1528 +      <ul class="rule">
 12.1529 +         <li>
 12.1530 +            Once a user has given permission, user agents should provide the ability for Web pages to communicate directly with a Local-networked Service.
 12.1531 +            <ul class="rule">
 12.1532 +               <li>
 12.1533 +                  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
 12.1534 +                  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
 12.1535 +                  application logic to communicate. Local devices providing the request service types are discovered and presented to the user for authorization. The user selects one
 12.1536 +                  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
 12.1537 +                  the user-authorized Local-networked services.
 12.1538 +               </li>
 12.1539 +            </ul>
 12.1540 +         </li>
 12.1541 +
 12.1542 +         <li>
 12.1543 +           Web pages should be able to communicate with Local-networked Services using the messaging channel supported by those Devices.
 12.1544 +           <ul class="rule">
 12.1545 +            <li>
 12.1546 +               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
 12.1547 +               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
 12.1548 +               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.
 12.1549 +            </li>
 12.1550 +           </ul>
 12.1551 +         </li>
 12.1552 +
 12.1553 +         <li>
 12.1554 +           Web pages should be able to communicate with Local-networked Services using the messaging format supported by those Devices.
 12.1555 +           <ul class="rule">
 12.1556 +            <li>
 12.1557 +               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
 12.1558 +               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
 12.1559 +               between <abbr title="Universal Plug-and-Play">UPnP</abbr>, 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
 12.1560 +               Server in the messaging format supported by that Device, which, in this example is a simple key/value pair text format.
 12.1561 +            </li>
 12.1562 +           </ul>
 12.1563 +         </li>
 12.1564 +
 12.1565 +         <li>
 12.1566 +           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.
 12.1567 +           <ul class="rule">
 12.1568 +            <li>
 12.1569 +               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
 12.1570 +               within the network, should not be accessible to the current Web page.
 12.1571 +            </li>
 12.1572 +           </ul>
 12.1573 +         </li>
 12.1574 +
 12.1575 +         <li>
 12.1576 +           A user should be able to share one or more Local-networked Services based on a particular service type request from a Web page.
 12.1577 +           <ul class="rule">
 12.1578 +            <li>
 12.1579 +               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
 12.1580 +               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
 12.1581 +               actions on to one or more of the authorized Local-networked Services.
 12.1582 +            </li>
 12.1583 +           </ul>
 12.1584 +         </li>
 12.1585 +
 12.1586 +         <li>
 12.1587 +           User agents should provide an <abbr title="Application Programming Interface">API</abbr> 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
 12.1588 +           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
 12.1589 +           these APIs occur silently without user intervention.
 12.1590 +         </li>
 12.1591 +      </ul>
 12.1592 +    </section>
 12.1593 +
 12.1594 +          <section id="examples" class="informative appendix">
 12.1595 +             <!--OddPage--><h2><span class="secno">A. </span>Examples</h2><p><em>This section is non-normative.</em></p>
 12.1596 +
 12.1597 +           <div class="example">
 12.1598 +            <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.
 12.1599 +            </p><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>
 12.1600 +            <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>
 12.1601 +            <hr>
 12.1602 +            <pre class="highlight prettyprint"><span class="tag">&lt;input</span><span class="pln"> </span><span class="atn">type</span><span class="pun">=</span><span class="atv">"button"</span><span class="pln"> </span><span class="atn">value</span><span class="pun">=</span><span class="atv">"Start"</span><span class="pln"> </span><span class="atn">onclick</span><span class="pun">=</span><span class="atv">"</span><span class="pln">start</span><span class="pun">()</span><span class="atv">"</span><span class="pln"> </span><span class="atn">id</span><span class="pun">=</span><span class="atv">"startBtn"</span><span class="tag">/&gt;</span><span class="pln">
 12.1603 +</span><span class="tag">&lt;div</span><span class="pln"> </span><span class="atn">id</span><span class="pun">=</span><span class="atv">"debugconsole"</span><span class="tag">&gt;&lt;/div&gt;</span><span class="pln">
 12.1604 +
 12.1605 +</span><span class="tag">&lt;script&gt;</span><span class="pln">
 12.1606 + </span><span class="kwd">var</span><span class="pln"> startBtn </span><span class="pun">=</span><span class="pln"> document</span><span class="pun">.</span><span class="pln">getElementById</span><span class="pun">(</span><span class="str">'startBtn'</span><span class="pun">),</span><span class="pln">
 12.1607 +     debug </span><span class="pun">=</span><span class="pln"> document</span><span class="pun">.</span><span class="pln">getElementById</span><span class="pun">(</span><span class="str">'debugconsole'</span><span class="pun">);</span><span class="pln">
 12.1608 +
 12.1609 + </span><span class="kwd">function</span><span class="pln"> start</span><span class="pun">()</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
 12.1610 +   </span><span class="kwd">if</span><span class="pun">(</span><span class="pln">navigator</span><span class="pun">.</span><span class="pln">getNetworkServices</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
 12.1611 +      navigator</span><span class="pun">.</span><span class="pln">getNetworkServices</span><span class="pun">(</span><span class="str">'zeroconf:_xbmc-jsonrpc._tcp'</span><span class="pun">,</span><span class="pln"> gotXBMCService</span><span class="pun">,</span><span class="pln"> error</span><span class="pun">);</span><span class="pln">
 12.1612 +      startBtn</span><span class="pun">.</span><span class="pln">disabled </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">true</span><span class="pun">;</span><span class="pln">
 12.1613 +   </span><span class="pun">}</span><span class="pln"> </span><span class="kwd">else</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
 12.1614 +      debug</span><span class="pun">.</span><span class="pln">innerHTML </span><span class="pun">+=</span><span class="pln"> </span><span class="str">"&lt;br&gt;Service Discovery API not supported!"</span><span class="pun">;</span><span class="pln">
 12.1615 +   </span><span class="pun">}</span><span class="pln">
 12.1616 + </span><span class="pun">}</span><span class="pln">
 12.1617 +
 12.1618 + </span><span class="kwd">function</span><span class="pln"> gotXBMCService</span><span class="pun">(</span><span class="pln">services</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
 12.1619 +
 12.1620 +</span><span class="com">// Listen for service disconnect messages</span><span class="pln">
 12.1621 +
 12.1622 +   services</span><span class="pun">[</span><span class="lit">0</span><span class="pun">].</span><span class="pln">addEventListener</span><span class="pun">(</span><span class="str">'readystatechange'</span><span class="pun">,</span><span class="pln"> </span><span class="kwd">function</span><span class="pln"> </span><span class="pun">(</span><span class="pln"> e </span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
 12.1623 +     </span><span class="kwd">if</span><span class="pun">(</span><span class="pln">services</span><span class="pun">[</span><span class="lit">0</span><span class="pun">].</span><span class="pln">readyState </span><span class="pun">===</span><span class="pln"> services</span><span class="pun">[</span><span class="lit">0</span><span class="pun">].</span><span class="pln">UNAVAILABLE</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
 12.1624 +       debug</span><span class="pun">.</span><span class="pln">innerHTML </span><span class="pun">+=</span><span class="pln"> </span><span class="str">"&lt;br&gt;"</span><span class="pln"> </span><span class="pun">+</span><span class="pln"> services</span><span class="pun">[</span><span class="lit">0</span><span class="pun">].</span><span class="pln">name </span><span class="pun">+</span><span class="pln"> </span><span class="str">" disconnected."</span><span class="pun">;</span><span class="pln">
 12.1625 +       startBtn</span><span class="pun">.</span><span class="pln">disabled </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">false</span><span class="pun">;</span><span class="pln">
 12.1626 +     </span><span class="pun">}</span><span class="pln">
 12.1627 +   </span><span class="pun">},</span><span class="pln"> </span><span class="kwd">false</span><span class="pun">);</span><span class="pln">
 12.1628 +
 12.1629 +</span><span class="com">// Send a service message to get albums list (and process the service response)</span><span class="pln">
 12.1630 +
 12.1631 +   </span><span class="kwd">var</span><span class="pln"> svcXhr </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">new</span><span class="pln"> </span><span class="typ">XMLHttpRequest</span><span class="pun">();</span><span class="pln">
 12.1632 +   svcXhr</span><span class="pun">.</span><span class="pln">open</span><span class="pun">(</span><span class="str">"POST"</span><span class="pun">,</span><span class="pln"> services</span><span class="pun">[</span><span class="lit">0</span><span class="pun">].</span><span class="pln">url </span><span class="pun">+</span><span class="pln"> </span><span class="str">"/getAlbums"</span><span class="pun">);</span><span class="pln"> </span><span class="com">// services[0].url and its subresources have been</span><span class="pln">
 12.1633 +                                                        </span><span class="com">// whitelisted for cross-site XHR use in this</span><span class="pln">
 12.1634 +                                                        </span><span class="com">// current browsing context.</span><span class="pln">
 12.1635 +
 12.1636 +   svcXhr</span><span class="pun">.</span><span class="pln">setRequestHeader</span><span class="pun">(</span><span class="str">'Content-Type'</span><span class="pun">,</span><span class="pln"> </span><span class="str">'application/json-rpc'</span><span class="pun">);</span><span class="pln">
 12.1637 +
 12.1638 +   svcXhr</span><span class="pun">.</span><span class="pln">addEventListener</span><span class="pun">(</span><span class="str">'readystatechange'</span><span class="pun">,</span><span class="pln"> </span><span class="kwd">function</span><span class="pln"> </span><span class="pun">(</span><span class="pln"> response </span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
 12.1639 +     </span><span class="kwd">if</span><span class="pun">(</span><span class="pln"> response</span><span class="pun">.</span><span class="pln">readyState </span><span class="pun">!=</span><span class="pln"> </span><span class="lit">4</span><span class="pln"> </span><span class="pun">||</span><span class="pln"> response</span><span class="pun">.</span><span class="pln">status </span><span class="pun">!=</span><span class="pln"> </span><span class="lit">200</span><span class="pln"> </span><span class="pun">)</span><span class="pln">
 12.1640 +        </span><span class="kwd">return</span><span class="pun">;</span><span class="pln">
 12.1641 +     debug</span><span class="pun">.</span><span class="pln">innerHTML </span><span class="pun">+=</span><span class="pln"> </span><span class="str">"&lt;br&gt;"</span><span class="pln"> </span><span class="pun">+</span><span class="pln"> services</span><span class="pun">[</span><span class="lit">0</span><span class="pun">].</span><span class="pln">name </span><span class="pun">+</span><span class="pln"> </span><span class="str">" response received: "</span><span class="pun">;</span><span class="pln">
 12.1642 +     debug</span><span class="pun">.</span><span class="pln">textContent </span><span class="pun">+=</span><span class="pln"> JSON</span><span class="pun">.</span><span class="pln">parse</span><span class="pun">(</span><span class="pln">response</span><span class="pun">.</span><span class="pln">responseText</span><span class="pun">);</span><span class="pln">
 12.1643 +   </span><span class="pun">},</span><span class="pln"> </span><span class="kwd">false</span><span class="pun">);</span><span class="pln">
 12.1644 +
 12.1645 +   </span><span class="kwd">var</span><span class="pln"> svcMsg </span><span class="pun">=</span><span class="pln"> </span><span class="pun">[</span><span class="pln">
 12.1646 +     </span><span class="pun">{</span><span class="pln"> </span><span class="str">"jsonrpc"</span><span class="pun">:</span><span class="pln"> </span><span class="str">"2.0"</span><span class="pun">,</span><span class="pln"> </span><span class="str">"method"</span><span class="pun">:</span><span class="pln"> </span><span class="str">"AudioLibrary.GetAlbums"</span><span class="pun">,</span><span class="pln"> </span><span class="str">"params"</span><span class="pun">:</span><span class="pln"> </span><span class="pun">{</span><span class="pln"> </span><span class="str">"genreid"</span><span class="pun">:</span><span class="pln"> </span><span class="pun">-</span><span class="lit">1</span><span class="pun">,</span><span class="pln">
 12.1647 +         </span><span class="str">"artistid"</span><span class="pun">:</span><span class="pln"> </span><span class="pun">-</span><span class="lit">1</span><span class="pun">,</span><span class="pln"> </span><span class="str">"start"</span><span class="pun">:</span><span class="pln"> </span><span class="pun">-</span><span class="lit">1</span><span class="pun">,</span><span class="pln"> </span><span class="str">"end"</span><span class="pun">:</span><span class="pln"> </span><span class="pun">-</span><span class="lit">1</span><span class="pln"> </span><span class="pun">},</span><span class="pln"> </span><span class="str">"id"</span><span class="pun">:</span><span class="pln"> </span><span class="str">"1"</span><span class="pln"> </span><span class="pun">}</span><span class="pln">
 12.1648 +   </span><span class="pun">];</span><span class="pln">
 12.1649 +
 12.1650 +   svcXhr</span><span class="pun">.</span><span class="pln">send</span><span class="pun">(</span><span class="pln">JSON</span><span class="pun">.</span><span class="pln">stringify</span><span class="pun">(</span><span class="pln">svcMsg</span><span class="pun">));</span><span class="pln">
 12.1651 +   debug</span><span class="pun">.</span><span class="pln">innerHTML </span><span class="pun">+=</span><span class="pln"> </span><span class="str">"&lt;br&gt;"</span><span class="pln"> </span><span class="pun">+</span><span class="pln"> services</span><span class="pun">[</span><span class="lit">0</span><span class="pun">].</span><span class="pln">name </span><span class="pun">+</span><span class="pln"> </span><span class="str">" request sent: "</span><span class="pun">;</span><span class="pln">
 12.1652 +   debug</span><span class="pun">.</span><span class="pln">textContent </span><span class="pun">+=</span><span class="pln"> JSON</span><span class="pun">.</span><span class="pln">stringify</span><span class="pun">(</span><span class="pln">svcMsg</span><span class="pun">);</span><span class="pln">
 12.1653 +
 12.1654 + </span><span class="pun">}</span><span class="pln">
 12.1655 +
 12.1656 + </span><span class="kwd">function</span><span class="pln"> error</span><span class="pun">(</span><span class="pln"> err </span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
 12.1657 +   debug</span><span class="pun">.</span><span class="pln">innerHTML </span><span class="pun">+=</span><span class="pln"> </span><span class="str">"&lt;br&gt;An error occurred obtaining a local network service."</span><span class="pun">;</span><span class="pln">
 12.1658 +   startBtn</span><span class="pun">.</span><span class="pln">disabled </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">false</span><span class="pun">;</span><span class="pln">
 12.1659 + </span><span class="pun">}</span><span class="pln">
 12.1660 +</span><span class="tag">&lt;/script&gt;</span></pre>
 12.1661 +           </div>
 12.1662 +
 12.1663 +           <div class="example">
 12.1664 +            <p>
 12.1665 +             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
 12.1666 +             based on the service type requested. The user may also select multiple network services matching the selected service type.
 12.1667 +             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
 12.1668 +             (<var>urn:schemas-upnp-org:service:RenderingControl:1</var>).
 12.1669 +             <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.
 12.1670 +            </p>
 12.1671 +            <hr>
 12.1672 +            <pre class="highlight prettyprint"><span class="tag">&lt;select</span><span class="pln"> </span><span class="atn">name</span><span class="pun">=</span><span class="atv">"make"</span><span class="pln"> </span><span class="atn">id</span><span class="pun">=</span><span class="atv">"make"</span><span class="tag">&gt;</span><span class="pln">
 12.1673 +  </span><span class="tag">&lt;option</span><span class="pln"> </span><span class="atn">selected</span><span class="pun">=</span><span class="atv">"selected"</span><span class="pln"> </span><span class="atn">disabled</span><span class="pun">=</span><span class="atv">"disabled"</span><span class="tag">&gt;</span><span class="pln">Select make</span><span class="tag">&lt;/option&gt;</span><span class="pln">
 12.1674 +  </span><span class="tag">&lt;option&gt;</span><span class="pln">Sony</span><span class="tag">&lt;/option&gt;</span><span class="pln">
 12.1675 +  </span><span class="tag">&lt;option&gt;</span><span class="pln">Philips</span><span class="tag">&lt;/option&gt;</span><span class="pln">
 12.1676 +  </span><span class="tag">&lt;option&gt;</span><span class="pln">Alba</span><span class="tag">&lt;/option&gt;</span><span class="pln">
 12.1677 +</span><span class="tag">&lt;/select&gt;</span><span class="pln">
 12.1678 +</span><span class="tag">&lt;select</span><span class="pln"> </span><span class="atn">name</span><span class="pun">=</span><span class="atv">"model"</span><span class="pln"> </span><span class="atn">id</span><span class="pun">=</span><span class="atv">"model"</span><span class="tag">&gt;&lt;/select&gt;</span><span class="pln">
 12.1679 +</span><span class="tag">&lt;div</span><span class="pln"> </span><span class="atn">id</span><span class="pun">=</span><span class="atv">"debugconsole"</span><span class="tag">&gt;&lt;/div&gt;</span><span class="pln">
 12.1680 +
 12.1681 +</span><span class="tag">&lt;script&gt;</span><span class="pln">
 12.1682 +  </span><span class="kwd">var</span><span class="pln"> debug </span><span class="pun">=</span><span class="pln"> document</span><span class="pun">.</span><span class="pln">getElementById</span><span class="pun">(</span><span class="str">'debugconsole'</span><span class="pun">);</span><span class="pln">
 12.1683 +
 12.1684 +  </span><span class="kwd">var</span><span class="pln"> models </span><span class="pun">=</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
 12.1685 +    </span><span class="str">"Sony"</span><span class="pun">:</span><span class="pln"> </span><span class="pun">[</span><span class="pln">
 12.1686 +      </span><span class="pun">{</span><span class="str">"name"</span><span class="pun">:</span><span class="pln"> </span><span class="str">"Bravia TV S1000"</span><span class="pun">,</span><span class="pln"> </span><span class="str">"type"</span><span class="pun">:</span><span class="pln"> </span><span class="str">"upnp"</span><span class="pun">,</span><span class="pln"> </span><span class="str">"service"</span><span class="pun">:</span><span class="pln"> </span><span class="str">"urn:schemas-upnp-org:service:RenderingControl:1"</span><span class="pln"> </span><span class="pun">},</span><span class="pln">
 12.1687 +      </span><span class="pun">{</span><span class="str">"name"</span><span class="pun">:</span><span class="pln"> </span><span class="str">"Bravia TV S2000"</span><span class="pun">,</span><span class="pln"> </span><span class="str">"type"</span><span class="pun">:</span><span class="pln"> </span><span class="str">"zeroconf"</span><span class="pun">,</span><span class="pln"> </span><span class="str">"service"</span><span class="pun">:</span><span class="pln"> </span><span class="str">"_mediarenderer._http._tcp"</span><span class="pln"> </span><span class="pun">},</span><span class="pln">
 12.1688 +      </span><span class="pun">{</span><span class="str">"name"</span><span class="pun">:</span><span class="pln"> </span><span class="str">"HiFi WD10"</span><span class="pun">,</span><span class="pln"> </span><span class="str">"type"</span><span class="pun">:</span><span class="pln"> </span><span class="str">"upnp"</span><span class="pun">,</span><span class="pln"> </span><span class="str">"service"</span><span class="pun">:</span><span class="pln"> </span><span class="str">"urn:schemas-upnp-org:service:RenderingControl:1"</span><span class="pln"> </span><span class="pun">}</span><span class="pln">
 12.1689 +    </span><span class="pun">],</span><span class="pln">
 12.1690 +    </span><span class="str">"Philips"</span><span class="pun">:</span><span class="pln"> </span><span class="pun">[</span><span class="pln"> </span><span class="com">/* ... */</span><span class="pln"> </span><span class="pun">],</span><span class="pln">
 12.1691 +    </span><span class="str">"Alba"</span><span class="pun">:</span><span class="pln"> </span><span class="pun">[</span><span class="pln"> </span><span class="com">/* ... */</span><span class="pln"> </span><span class="pun">]</span><span class="pln">
 12.1692 +  </span><span class="pun">};</span><span class="pln">
 12.1693 +
 12.1694 +  </span><span class="kwd">var</span><span class="pln"> makeEl </span><span class="pun">=</span><span class="pln"> document</span><span class="pun">.</span><span class="pln">getElementById</span><span class="pun">(</span><span class="str">"make"</span><span class="pun">),</span><span class="pln">
 12.1695 +      modelEl </span><span class="pun">=</span><span class="pln"> document</span><span class="pun">.</span><span class="pln">getElementById</span><span class="pun">(</span><span class="str">"model"</span><span class="pun">);</span><span class="pln">
 12.1696 +
 12.1697 +  makeEl</span><span class="pun">.</span><span class="pln">addEventListener</span><span class="pun">(</span><span class="str">'change'</span><span class="pun">,</span><span class="pln"> </span><span class="kwd">function</span><span class="pun">()</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
 12.1698 +    modelEl</span><span class="pun">.</span><span class="pln">innerHTML </span><span class="pun">=</span><span class="pln"> </span><span class="str">""</span><span class="pun">;</span><span class="pln"> </span><span class="com">// reset</span><span class="pln">
 12.1699 +    </span><span class="kwd">var</span><span class="pln"> defaultOption </span><span class="pun">=</span><span class="pln"> document</span><span class="pun">.</span><span class="pln">createElement</span><span class="pun">(</span><span class="str">"option"</span><span class="pun">);</span><span class="pln">
 12.1700 +    defaultOption</span><span class="pun">.</span><span class="pln">textContent </span><span class="pun">=</span><span class="pln"> </span><span class="str">"Select model"</span><span class="pun">;</span><span class="pln">
 12.1701 +    defaultOption</span><span class="pun">.</span><span class="pln">setAttribute</span><span class="pun">(</span><span class="str">"disabled"</span><span class="pun">,</span><span class="pln"> </span><span class="str">"disabled"</span><span class="pun">);</span><span class="pln">
 12.1702 +    defaultOption</span><span class="pun">.</span><span class="pln">setAttribute</span><span class="pun">(</span><span class="str">"selected"</span><span class="pun">,</span><span class="pln"> </span><span class="str">"selected"</span><span class="pun">);</span><span class="pln">
 12.1703 +    modelEl</span><span class="pun">.</span><span class="pln">appendChild</span><span class="pun">(</span><span class="pln">defaultOption</span><span class="pun">);</span><span class="pln">
 12.1704 +    </span><span class="kwd">for</span><span class="pun">(</span><span class="kwd">var</span><span class="pln"> i </span><span class="pun">=</span><span class="pln"> </span><span class="lit">0</span><span class="pun">,</span><span class="pln"> l </span><span class="pun">=</span><span class="pln"> models</span><span class="pun">[</span><span class="pln">makeEl</span><span class="pun">.</span><span class="pln">value</span><span class="pun">].</span><span class="pln">length</span><span class="pun">;</span><span class="pln"> i </span><span class="pun">&lt;</span><span class="pln"> l</span><span class="pun">;</span><span class="pln"> i</span><span class="pun">++)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
 12.1705 +      </span><span class="kwd">var</span><span class="pln"> option </span><span class="pun">=</span><span class="pln"> document</span><span class="pun">.</span><span class="pln">createElement</span><span class="pun">(</span><span class="str">"option"</span><span class="pun">);</span><span class="pln">
 12.1706 +      option</span><span class="pun">.</span><span class="pln">textContent </span><span class="pun">=</span><span class="pln"> models</span><span class="pun">[</span><span class="pln">makeEl</span><span class="pun">.</span><span class="pln">value</span><span class="pun">][</span><span class="pln">i</span><span class="pun">][</span><span class="str">"name"</span><span class="pun">];</span><span class="pln">
 12.1707 +      option</span><span class="pun">.</span><span class="pln">setAttribute</span><span class="pun">(</span><span class="str">"value"</span><span class="pun">,</span><span class="pln"> models</span><span class="pun">[</span><span class="pln">makeEl</span><span class="pun">.</span><span class="pln">value</span><span class="pun">][</span><span class="pln">i</span><span class="pun">][</span><span class="str">"type"</span><span class="pun">]</span><span class="pln"> </span><span class="pun">+</span><span class="pln"> </span><span class="str">":"</span><span class="pln"> </span><span class="pun">+</span><span class="pln"> models</span><span class="pun">[</span><span class="pln">makeEl</span><span class="pun">.</span><span class="pln">value</span><span class="pun">][</span><span class="pln">i</span><span class="pun">][</span><span class="str">"service"</span><span class="pun">]);</span><span class="pln">
 12.1708 +      modelEl</span><span class="pun">.</span><span class="pln">appendChild</span><span class="pun">(</span><span class="pln">option</span><span class="pun">);</span><span class="pln">
 12.1709 +    </span><span class="pun">}</span><span class="pln">
 12.1710 +  </span><span class="pun">},</span><span class="pln"> </span><span class="kwd">false</span><span class="pun">);</span><span class="pln">
 12.1711 +
 12.1712 +  modelEl</span><span class="pun">.</span><span class="pln">addEventListener</span><span class="pun">(</span><span class="str">'change'</span><span class="pun">,</span><span class="pln"> </span><span class="kwd">function</span><span class="pun">()</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
 12.1713 +    </span><span class="kwd">if</span><span class="pun">(</span><span class="pln">navigator</span><span class="pun">.</span><span class="pln">getNetworkServices </span><span class="pun">&amp;&amp;</span><span class="pln">
 12.1714 +         modelEl</span><span class="pun">.</span><span class="pln">value </span><span class="pun">==</span><span class="pln"> </span><span class="str">"upnp:urn:schemas-upnp-org:service:RenderingControl:1"</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
 12.1715 +      navigator</span><span class="pun">.</span><span class="pln">getNetworkServices</span><span class="pun">(</span><span class="pln">modelEl</span><span class="pun">.</span><span class="pln">value</span><span class="pun">,</span><span class="pln"> successCallback</span><span class="pun">,</span><span class="pln"> errorCallback</span><span class="pun">);</span><span class="pln">
 12.1716 +    </span><span class="pun">}</span><span class="pln"> </span><span class="kwd">else</span><span class="pln"> </span><span class="kwd">if</span><span class="pln"> </span><span class="pun">(</span><span class="pln">modelEl</span><span class="pun">.</span><span class="pln">value </span><span class="pun">==</span><span class="pln"> </span><span class="str">"zeroconf:_mediarenderer._http._tcp"</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
 12.1717 +      debug</span><span class="pun">.</span><span class="pln">innerHTML </span><span class="pun">+=</span><span class="pln"> </span><span class="str">"&lt;br&gt;Service type is not implemented by this application."</span><span class="pun">;</span><span class="pln">
 12.1718 +    </span><span class="pun">}</span><span class="pln"> </span><span class="kwd">else</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
 12.1719 +      debug</span><span class="pun">.</span><span class="pln">innerHTML </span><span class="pun">+=</span><span class="pln"> </span><span class="str">"&lt;br&gt;Service Discovery is not supported!"</span><span class="pun">;</span><span class="pln">
 12.1720 +    </span><span class="pun">}</span><span class="pln">
 12.1721 +  </span><span class="pun">},</span><span class="pln"> </span><span class="kwd">false</span><span class="pun">);</span><span class="pln">
 12.1722 +</span><span class="tag">&lt;/script&gt;</span><span class="pln">
 12.1723 +
 12.1724 +</span><span class="tag">&lt;script&gt;</span><span class="pln">
 12.1725 +  </span><span class="kwd">function</span><span class="pln"> successCallback</span><span class="pun">(</span><span class="pln"> services </span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
 12.1726 +
 12.1727 +  </span><span class="com">// Listen for service push messages</span><span class="pln">
 12.1728 +
 12.1729 +    services</span><span class="pun">[</span><span class="lit">0</span><span class="pun">].</span><span class="pln">addEventListener</span><span class="pun">(</span><span class="str">'message'</span><span class="pun">,</span><span class="pln"> </span><span class="kwd">function</span><span class="pln"> </span><span class="pun">(</span><span class="pln"> msg </span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
 12.1730 +         debug</span><span class="pun">.</span><span class="pln">innerHTML </span><span class="pun">+=</span><span class="pln"> </span><span class="str">"&lt;br&gt;"</span><span class="pln"> </span><span class="pun">+</span><span class="pln"> services</span><span class="pun">[</span><span class="lit">0</span><span class="pun">].</span><span class="pln">name </span><span class="pun">+</span><span class="pln"> </span><span class="str">" event received: "</span><span class="pun">;</span><span class="pln">
 12.1731 +         debug</span><span class="pun">.</span><span class="pln">textContent </span><span class="pun">+=</span><span class="pln"> msg</span><span class="pun">.</span><span class="pln">data</span><span class="pun">;</span><span class="pln">
 12.1732 +    </span><span class="pun">},</span><span class="pln"> </span><span class="kwd">false</span><span class="pun">);</span><span class="pln">
 12.1733 +
 12.1734 + </span><span class="com">// Send a control signal to mute the service audio</span><span class="pln">
 12.1735 +
 12.1736 +    </span><span class="kwd">var</span><span class="pln"> svcXhr </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">new</span><span class="pln"> </span><span class="typ">XMLHttpRequest</span><span class="pun">();</span><span class="pln">
 12.1737 +    svcXhr</span><span class="pun">.</span><span class="pln">open</span><span class="pun">(</span><span class="str">"POST"</span><span class="pun">,</span><span class="pln"> services</span><span class="pun">[</span><span class="lit">0</span><span class="pun">].</span><span class="pln">url</span><span class="pun">);</span><span class="pln"> </span><span class="com">// services[0].url and its</span><span class="pln">
 12.1738 +                                          </span><span class="com">// subresources have been whitelisted for</span><span class="pln">
 12.1739 +                                          </span><span class="com">// cross-site XHR use in this current</span><span class="pln">
 12.1740 +                                          </span><span class="com">// browsing context.</span><span class="pln">
 12.1741 +
 12.1742 +    svcXhr</span><span class="pun">.</span><span class="pln">setRequestHeader</span><span class="pun">(</span><span class="str">'SOAPAction'</span><span class="pun">,</span><span class="pln"> </span><span class="str">'urn:schemas-upnp-org:service:RenderingControl:1#SetMute'</span><span class="pun">);</span><span class="pln">
 12.1743 +    svcXhr</span><span class="pun">.</span><span class="pln">setRequestHeader</span><span class="pun">(</span><span class="str">'Content-Type'</span><span class="pun">,</span><span class="pln"> </span><span class="str">'text/xml; charset="utf-8";'</span><span class="pun">);</span><span class="pln">
 12.1744 +
 12.1745 +    svcXhr</span><span class="pun">.</span><span class="pln">onreadystatechange </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">function</span><span class="pln"> </span><span class="pun">(</span><span class="pln"> response </span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
 12.1746 +      </span><span class="kwd">if</span><span class="pun">(</span><span class="pln"> response</span><span class="pun">.</span><span class="pln">readyState </span><span class="pun">!=</span><span class="pln"> </span><span class="lit">4</span><span class="pln"> </span><span class="pun">||</span><span class="pln"> response</span><span class="pun">.</span><span class="pln">status </span><span class="pun">!=</span><span class="pln"> </span><span class="lit">200</span><span class="pln"> </span><span class="pun">)</span><span class="pln">
 12.1747 +        </span><span class="kwd">return</span><span class="pun">;</span><span class="pln">
 12.1748 +      debug</span><span class="pun">.</span><span class="pln">innerHTML </span><span class="pun">+=</span><span class="pln"> </span><span class="str">"&lt;br&gt;"</span><span class="pln"> </span><span class="pun">+</span><span class="pln"> services</span><span class="pun">[</span><span class="lit">0</span><span class="pun">].</span><span class="pln">name </span><span class="pun">+</span><span class="pln"> </span><span class="str">" response received: "</span><span class="pun">;</span><span class="pln">
 12.1749 +      debug</span><span class="pun">.</span><span class="pln">textContent </span><span class="pun">+=</span><span class="pln"> response</span><span class="pun">.</span><span class="pln">responseXML</span><span class="pun">;</span><span class="pln">
 12.1750 +    </span><span class="pun">}</span><span class="pln">
 12.1751 +
 12.1752 +    </span><span class="com">// Service messaging to mute the provided service</span><span class="pln">
 12.1753 +    </span><span class="kwd">var</span><span class="pln"> svcMsg </span><span class="pun">=</span><span class="pln"> </span><span class="str">'&lt;?xml version="1.0" encoding="utf-8"?&gt;'</span><span class="pln"> </span><span class="pun">+</span><span class="pln">
 12.1754 +                 </span><span class="str">'&lt;s:Envelope s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" '</span><span class="pln"> </span><span class="pun">+</span><span class="pln">
 12.1755 +                   </span><span class="str">'xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"&gt;'</span><span class="pln"> </span><span class="pun">+</span><span class="pln">
 12.1756 +                   </span><span class="str">'&lt;s:Body&gt;'</span><span class="pln"> </span><span class="pun">+</span><span class="pln">
 12.1757 +                     </span><span class="str">'&lt;u:SetMute xmlns:u="urn:schemas-upnp-org:service:RenderingControl:1"&gt;'</span><span class="pln"> </span><span class="pun">+</span><span class="pln">
 12.1758 +                       </span><span class="str">'&lt;InstanceID&gt;0&lt;/InstanceID&gt;'</span><span class="pln"> </span><span class="pun">+</span><span class="pln">
 12.1759 +                       </span><span class="str">'&lt;Channel&gt;Master&lt;/Channel&gt;'</span><span class="pln"> </span><span class="pun">+</span><span class="pln">
 12.1760 +                       </span><span class="str">'&lt;DesiredMute&gt;true&lt;/DesiredMute&gt;'</span><span class="pln"> </span><span class="pun">+</span><span class="pln">
 12.1761 +                     </span><span class="str">'&lt;/u:SetMute&gt;'</span><span class="pln"> </span><span class="pun">+</span><span class="pln">
 12.1762 +                   </span><span class="str">'&lt;/s:Body&gt;'</span><span class="pln"> </span><span class="pun">+</span><span class="pln">
 12.1763 +                 </span><span class="str">'&lt;/s:Envelope&gt;'</span><span class="pun">;</span><span class="pln">
 12.1764 +
 12.1765 +    svcXhr</span><span class="pun">.</span><span class="pln">send</span><span class="pun">(</span><span class="pln">svcMsg</span><span class="pun">);</span><span class="pln">
 12.1766 +    debug</span><span class="pun">.</span><span class="pln">innerHTML </span><span class="pun">+=</span><span class="pln"> </span><span class="str">"&lt;br&gt;"</span><span class="pln"> </span><span class="pun">+</span><span class="pln"> services</span><span class="pun">[</span><span class="lit">0</span><span class="pun">].</span><span class="pln">name </span><span class="pun">+</span><span class="pln"> </span><span class="str">" request sent: "</span><span class="pun">;</span><span class="pln">
 12.1767 +    debug</span><span class="pun">.</span><span class="pln">textContent </span><span class="pun">+=</span><span class="pln"> svcMsg</span><span class="pun">;</span><span class="pln">
 12.1768 +  </span><span class="pun">}</span><span class="pln">
 12.1769 +
 12.1770 +  </span><span class="kwd">function</span><span class="pln"> errorCallback</span><span class="pun">(</span><span class="pln"> error </span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
 12.1771 +    debug</span><span class="pun">.</span><span class="pln">innerHTML </span><span class="pun">+=</span><span class="pln"> </span><span class="str">"&lt;br&gt;An error occurred: "</span><span class="pln"> </span><span class="pun">+</span><span class="pln"> error</span><span class="pun">.</span><span class="pln">code</span><span class="pun">;</span><span class="pln">
 12.1772 +  </span><span class="pun">}</span><span class="pln">
 12.1773 +</span><span class="tag">&lt;/script&gt;</span></pre>
 12.1774 +          </div>
 12.1775 +
 12.1776 +       </section>
 12.1777 +
 12.1778 +    <section id="acknowledgements">
 12.1779 +      <!--OddPage--><h2><span class="secno">B. </span>Acknowledgements</h2>
 12.1780 +
 12.1781 +      <p>Thanks are expressed by the editor to the following individuals for their feedback on this specification to date (in alphabetical order):
 12.1782 +      <br><br>
 12.1783 +      Gar Bergstedt, Lars-Erik Bolstad, Hari G Kumar, Bob Lund, Giuseppe Pascale, Marcin Simonides, Clarke Stevens, Christian Söderström, Mark Vickers, ...</p>
 12.1784 +
 12.1785 +      <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):
 12.1786 +      <br><br>
 12.1787 +      CableLabs, Opera Software ASA, <abbr title="World Wide Web Consortium">W3C</abbr> Device APIs Working Group, <abbr title="World Wide Web Consortium">W3C</abbr> Web and TV Interest Group, ...</p>
 12.1788 +    </section>
 12.1789 +
 12.1790 +
 12.1791 +<section class="appendix" id="references"><!--OddPage--><h2><span class="secno">C. </span>References</h2><section id="normative-references"><h3><span class="secno">C.1 </span>Normative references</h3><dl class="bibliography"><dt id="bib-DNS-SD">[DNS-SD]</dt><dd>S. Cheshire; M. Krochmal. <a href="http://files.dns-sd.org/draft-cheshire-dnsext-dns-sd.txt"><cite>DNS-Based Service Discovery.</cite></a> 27 February 2011. IETF Draft. URL: <a href="http://files.dns-sd.org/draft-cheshire-dnsext-dns-sd.txt">http://files.dns-sd.org/draft-cheshire-dnsext-dns-sd.txt</a>
 12.1792 +</dd><dt id="bib-DOM4">[DOM4]</dt><dd>Anne van Kesteren; Aryeh Gregor; Ms2ger. <a href="http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html/"><cite>DOM4.</cite></a> URL: <a href="http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html/">http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html/</a> 
 12.1793 +</dd><dt id="bib-HTML5">[HTML5]</dt><dd>Ian Hickson; David Hyatt. <a href="http://www.w3.org/TR/html5"><cite>HTML5.</cite></a> 25 May 2011. W3C Working Draft. (Work in progress.) URL: <a href="http://www.w3.org/TR/html5">http://www.w3.org/TR/html5</a> 
 12.1794 +</dd><dt id="bib-MDNS">[MDNS]</dt><dd>S. Cheshire; M. Krochmal. <a href="http://files.multicastdns.org/draft-cheshire-dnsext-multicastdns.txt"><cite>Multicast DNS.</cite></a> 14 February 2011. IETF Draft. URL: <a href="http://files.multicastdns.org/draft-cheshire-dnsext-multicastdns.txt">http://files.multicastdns.org/draft-cheshire-dnsext-multicastdns.txt</a>
 12.1795 +</dd><dt id="bib-POSTMSG">[POSTMSG]</dt><dd>Ian Hickson. <a href="http://dev.w3.org/html5/postmsg"><cite>HTML5 Web Messaging.</cite></a> URL: <a href="http://dev.w3.org/html5/postmsg">http://dev.w3.org/html5/postmsg</a>
 12.1796 +</dd><dt id="bib-RFC2119">[RFC2119]</dt><dd>S. Bradner. <a href="http://www.ietf.org/rfc/rfc2119.txt"><cite>Key words for use in RFCs to Indicate Requirement Levels.</cite></a> March 1997. Internet RFC 2119.  URL: <a href="http://www.ietf.org/rfc/rfc2119.txt">http://www.ietf.org/rfc/rfc2119.txt</a> 
 12.1797 +</dd><dt id="bib-UPNP-DEVICEARCH11">[UPNP-DEVICEARCH11]</dt><dd><a href="http://upnp.org/specs/arch/UPnP-arch-DeviceArchitecture-v1.1.pdf"><cite>UPnP Device Architecture 1.1</cite></a>. 15 October 2008. UPnP Forum. PDF document. URL: <a href="http://upnp.org/specs/arch/UPnP-arch-DeviceArchitecture-v1.1.pdf">http://upnp.org/specs/arch/UPnP-arch-DeviceArchitecture-v1.1.pdf</a>
 12.1798 +</dd><dt id="bib-WEBIDL">[WEBIDL]</dt><dd>Cameron McCormack. <a href="http://www.w3.org/TR/2011/WD-WebIDL-20110927/"><cite>Web IDL.</cite></a> 27 September 2011. W3C Working Draft. (Work in progress.) URL: <a href="http://www.w3.org/TR/2011/WD-WebIDL-20110927/">http://www.w3.org/TR/2011/WD-WebIDL-20110927/</a> 
 12.1799 +</dd><dt id="bib-ZEROCONF">[ZEROCONF]</dt><dd>S. Cheshire; B. Aboba; E. Guttman. <a href="http://files.zeroconf.org/rfc3927.txt"><cite>Dynamic Configuration of IPv4 Link-Local Addresses.</cite></a> May 2005. IETF Draft. URL: <a href="http://files.zeroconf.org/rfc3927.txt">http://files.zeroconf.org/rfc3927.txt</a>
 12.1800 +</dd></dl></section><section id="informative-references"><h3><span class="secno">C.2 </span>Informative references</h3><p>No informative references.</p></section></section></body></html>
 12.1801 \ No newline at end of file
    13.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    13.2 +++ b/discovery-api/Overview.html	Mon Sep 03 15:35:05 2012 +0200
    13.3 @@ -0,0 +1,1809 @@
    13.4 +<!DOCTYPE html>
    13.5 +<html lang="en" dir="ltr">
    13.6 +<head>
    13.7 +    <title>Networked Service Discovery and Messaging</title>
    13.8 +    <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
    13.9 +
   13.10 +
   13.11 +
   13.12 +    <style type="text/css">
   13.13 +      /* Custom CSS optimizations (Richard Tibbett) */
   13.14 +
   13.15 +      /* Add better spacing to sections */
   13.16 +      section, .section { margin-bottom: 2em; }
   13.17 +
   13.18 +      /* Reduce note & issue render size */
   13.19 +      .note, .issue { font-size:0.8em; }
   13.20 +
   13.21 +      /* Add addition spacing to <ol> and <ul> for rule definition */
   13.22 +      ol.rule li, ul.rule li { padding:0.6em; }
   13.23 +
   13.24 +      pre.widl { border: solid thin; background: #EEEEEE; color: black; padding: 0.5em 1em; position: relative; }
   13.25 +      pre.widl :link, pre.widl :visited { color: #000; background: transparent; }
   13.26 +      pre.widl:before { content: "IDL"; font: bold small sans-serif; padding: 0.5em; background: white; position: absolute; top: 0; margin: -1px 0 0 -4em; width: 1.5em; border: thin solid; border-radius: 0 0 0 0.5em }
   13.27 +
   13.28 +      div.example { border: solid thin red; background: #F7DFE5; color: black; padding: 0.5em 1em; position: relative; margin: 1em 0 1em 4.6em; width: auto; }
   13.29 +      div.example:before { content: "EXAMPLE"; font: bold small sans-serif; padding: 0.5em; background: red; color: white; position: absolute; top: 0; margin: -1px 0 0 -7.6em; width: 5em; border: thin solid red; border-radius: 0 0 0 0.5em }
   13.30 +
   13.31 +      dl.domintro { color: green; margin: 2em 0 2em 2em; padding: 0.5em 1em; border: none; background: #DDFFDD; }
   13.32 +      hr + dl.domintro, div.impl + dl.domintro { margin-top: 2.5em; margin-bottom: 1.5em; }
   13.33 +      dl.domintro dt, dl.domintro dt * { color: black; text-decoration: none; }
   13.34 +      dl.domintro dd { margin: 0.5em 0 1em 2em; padding: 0; }
   13.35 +      dl.domintro dd p { margin: 0.5em 0; }
   13.36 +      dl.domintro code {font-size: inherit; font-style: italic; }
   13.37 +      dl.domintro:before { display: table; margin: -1em -0.5em 0.5em auto; width: auto; content: 'This box is non-normative. Implementation requirements are given below this box.'; color: red; border: solid 2px; background: white; padding: 0 0.25em; }
   13.38 +    </style>
   13.39 +  <style>/*****************************************************************
   13.40 + * ReSpec 3 CSS
   13.41 + * Robin Berjon - http://berjon.com/
   13.42 + *****************************************************************/
   13.43 +
   13.44 +/* --- INLINES --- */
   13.45 +em.rfc2119 {
   13.46 +    text-transform:     lowercase;
   13.47 +    font-variant:       small-caps;
   13.48 +    font-style:         normal;
   13.49 +    color:              #900;
   13.50 +}
   13.51 +
   13.52 +h1 acronym, h2 acronym, h3 acronym, h4 acronym, h5 acronym, h6 acronym, a acronym,
   13.53 +h1 abbr, h2 abbr, h3 abbr, h4 abbr, h5 abbr, h6 abbr, a abbr {
   13.54 +    border: none;
   13.55 +}
   13.56 +
   13.57 +dfn {
   13.58 +    font-weight:    bold;
   13.59 +}
   13.60 +
   13.61 +a.internalDFN {
   13.62 +    color:  inherit;
   13.63 +    border-bottom:  1px solid #99c;
   13.64 +    text-decoration:    none;
   13.65 +}
   13.66 +
   13.67 +a.externalDFN {
   13.68 +    color:  inherit;
   13.69 +    border-bottom:  1px dotted #ccc;
   13.70 +    text-decoration:    none;
   13.71 +}
   13.72 +
   13.73 +a.bibref {
   13.74 +    text-decoration:    none;
   13.75 +}
   13.76 +
   13.77 +cite .bibref {
   13.78 +    font-style: normal;
   13.79 +}
   13.80 +
   13.81 +code {
   13.82 +    color:  #ff4500;
   13.83 +}
   13.84 +
   13.85 +
   13.86 +/* --- --- */
   13.87 +ol.algorithm { counter-reset:numsection; list-style-type: none; }
   13.88 +ol.algorithm li { margin: 0.5em 0; }
   13.89 +ol.algorithm li:before { font-weight: bold; counter-increment: numsection; content: counters(numsection, ".") ") "; }
   13.90 +
   13.91 +/* --- TOC --- */
   13.92 +.toc a, .tof a {
   13.93 +    text-decoration:    none;
   13.94 +}
   13.95 +
   13.96 +a .secno, a .figno {
   13.97 +    color:  #000;
   13.98 +}
   13.99 +
  13.100 +ul.tof, ol.tof {
  13.101 +    list-style: none outside none;
  13.102 +}
  13.103 +
  13.104 +.caption {
  13.105 +    margin-top: 0.5em;
  13.106 +    font-style:   italic;
  13.107 +}
  13.108 +
  13.109 +/* --- TABLE --- */
  13.110 +table.simple {
  13.111 +    border-spacing: 0;
  13.112 +    border-collapse:    collapse;
  13.113 +    border-bottom:  3px solid #005a9c;
  13.114 +}
  13.115 +
  13.116 +.simple th {
  13.117 +    background: #005a9c;
  13.118 +    color:  #fff;
  13.119 +    padding:    3px 5px;
  13.120 +    text-align: left;
  13.121 +}
  13.122 +
  13.123 +.simple th[scope="row"] {
  13.124 +    background: inherit;
  13.125 +    color:  inherit;
  13.126 +    border-top: 1px solid #ddd;
  13.127 +}
  13.128 +
  13.129 +.simple td {
  13.130 +    padding:    3px 10px;
  13.131 +    border-top: 1px solid #ddd;
  13.132 +}
  13.133 +
  13.134 +.simple tr:nth-child(even) {
  13.135 +    background: #f0f6ff;
  13.136 +}
  13.137 +
  13.138 +/* --- DL --- */
  13.139 +.section dd > p:first-child {
  13.140 +    margin-top: 0;
  13.141 +}
  13.142 +
  13.143 +.section dd > p:last-child {
  13.144 +    margin-bottom: 0;
  13.145 +}
  13.146 +
  13.147 +.section dd {
  13.148 +    margin-bottom:  1em;
  13.149 +}
  13.150 +
  13.151 +.section dl.attrs dd, .section dl.eldef dd {
  13.152 +    margin-bottom:  0;
  13.153 +}
  13.154 +</style><style>/* --- ISSUES/NOTES --- */
  13.155 +div.issue-title, div.note-title {
  13.156 +    padding-right:  1em;
  13.157 +    min-width: 7.5em;
  13.158 +    color: #b9ab2d;
  13.159 +}
  13.160 +div.issue-title { color: #e05252; }
  13.161 +div.note-title { color: #52e052; }
  13.162 +div.issue-title span, div.note-title span {
  13.163 +    text-transform: uppercase;
  13.164 +}
  13.165 +div.note, div.issue {
  13.166 +    margin-top: 1em;
  13.167 +    margin-bottom: 1em;
  13.168 +}
  13.169 +.note > p:first-child, .issue > p:first-child { margin-top: 0 }
  13.170 +.issue, .note {
  13.171 +    padding: .5em;
  13.172 +    border-left-width: .5em;
  13.173 +    border-left-style: solid;
  13.174 +}
  13.175 +div.issue, div.note {
  13.176 +    padding: 0.5em;
  13.177 +    margin: 1em 0;
  13.178 +    position: relative;
  13.179 +    clear: both;
  13.180 +}
  13.181 +span.note, span.issue { padding: .1em .5em .15em; }
  13.182 +
  13.183 +.issue {
  13.184 +    border-color: #e05252;
  13.185 +    background: #fbe9e9;
  13.186 +}
  13.187 +.note {
  13.188 +    border-color: #52e052;
  13.189 +    background: #e9fbe9;
  13.190 +}
  13.191 +
  13.192 +
  13.193 +</style><style>/* HIGHLIGHTS */
  13.194 +code.prettyprint {
  13.195 +    color:  inherit;
  13.196 +}
  13.197 +
  13.198 +/* this from google-code-prettify */
  13.199 +.pln{color:#000}@media screen{.str{color:#080}.kwd{color:#008}.com{color:#800}.typ{color:#606}.lit{color:#066}.pun,.opn,.clo{color:#660}.tag{color:#008}.atn{color:#606}.atv{color:#080}.dec,.var{color:#606}.fun{color:red}}@media print,projection{.str{color:#060}.kwd{color:#006;font-weight:bold}.com{color:#600;font-style:italic}.typ{color:#404;font-weight:bold}.lit{color:#044}.pun,.opn,.clo{color:#440}.tag{color:#006;font-weight:bold}.atn{color:#404}.atv{color:#060}}ol.linenums{margin-top:0;margin-bottom:0}li.L0,li.L1,li.L2,li.L3,li.L5,li.L6,li.L7,li.L8{list-style-type:none}li.L1,li.L3,li.L5,li.L7,li.L9{background:#eee}
  13.200 +</style><link rel="stylesheet" href="http://www.w3.org/StyleSheets/TR/W3C-ED"><!--[if lt IE 9]><script src='undefined://www.w3.org/2008/site/js/html5shiv.js'></script><![endif]--></head>
  13.201 +
  13.202 +  <body><div class="head">
  13.203 +  <p>
  13.204 +
  13.205 +      <a href="http://www.w3.org/"><img width="72" height="48" src="http://www.w3.org/Icons/w3c_home" alt="W3C"></a>
  13.206 +
  13.207 +  </p>
  13.208 +  <h1 class="title" id="title">Networked Service Discovery and Messaging</h1>
  13.209 +
  13.210 +  <h2 id="w3c-editor-s-draft-22-august-2012"><abbr title="World Wide Web Consortium">W3C</abbr> Editor's Draft 22 August 2012</h2>
  13.211 +  <dl>
  13.212 +
  13.213 +      <dt>This version:</dt>
  13.214 +      <dd><a href="http://w3c-test.org/dap/discovery-api/">http://w3c-test.org/dap/discovery-api/</a></dd>
  13.215 +      <dt>Latest published version:</dt>
  13.216 +      <dd><a href="http://www.w3.org/TR/discovery-api/">http://www.w3.org/TR/discovery-api/</a></dd>
  13.217 +
  13.218 +
  13.219 +      <dt>Latest editor's draft:</dt>
  13.220 +      <dd><a href="http://w3c-test.org/dap/discovery-api/">http://w3c-test.org/dap/discovery-api/</a></dd>
  13.221 +
  13.222 +
  13.223 +
  13.224 +
  13.225 +
  13.226 +
  13.227 +
  13.228 +
  13.229 +    <dt>Editors:</dt>
  13.230 +    <dd><span>Rich Tibbett</span>, <a href="http://opera.com/">Opera Software ASA</a></dd>
  13.231 +<dd><span>Clarke Stevens</span>, <a href="http://cablelabs.com/">CableLabs</a></dd>
  13.232 +
  13.233 +
  13.234 +  </dl>
  13.235 +
  13.236 +
  13.237 +
  13.238 +
  13.239 +
  13.240 +      <p class="copyright">
  13.241 +        <a href="http://www.w3.org/Consortium/Legal/ipr-notice#Copyright">Copyright</a> ©
  13.242 +        2012
  13.243 +
  13.244 +        <a href="http://www.w3.org/"><abbr title="World Wide Web Consortium">W3C</abbr></a><sup>®</sup>
  13.245 +        (<a href="http://www.csail.mit.edu/"><abbr title="Massachusetts Institute of Technology">MIT</abbr></a>,
  13.246 +        <a href="http://www.ercim.eu/"><abbr title="European Research Consortium for Informatics and Mathematics">ERCIM</abbr></a>,
  13.247 +        <a href="http://www.keio.ac.jp/">Keio</a>), All Rights Reserved.
  13.248 +        <abbr title="World Wide Web Consortium">W3C</abbr> <a href="http://www.w3.org/Consortium/Legal/ipr-notice#Legal_Disclaimer">liability</a>,
  13.249 +        <a href="http://www.w3.org/Consortium/Legal/ipr-notice#W3C_Trademarks">trademark</a> and
  13.250 +        <a href="http://www.w3.org/Consortium/Legal/copyright-documents">document use</a> rules apply.
  13.251 +      </p>
  13.252 +
  13.253 +
  13.254 +  <hr>
  13.255 +</div>
  13.256 +    <section id="abstract" class="introductory"><h2>Abstract</h2>
  13.257 +      <p>
  13.258 +        This specification defines a mechanism for an HTML document to discover and subsequently communicate with <abbr title="Hypertext Transfer Protocol">HTTP</abbr>-based services
  13.259 +        advertised via common discovery protocols within a user's network.
  13.260 +      </p>
  13.261 +    </section><section id="sotd" class="introductory"><h2>Status of This Document</h2>
  13.262 +
  13.263 +
  13.264 +
  13.265 +        <p>
  13.266 +          <em>This section describes the status of this document at the time of its publication. Other
  13.267 +          documents may supersede this document. A list of current <abbr title="World Wide Web Consortium">W3C</abbr> publications and the latest revision
  13.268 +          of this technical report can be found in the <a href="http://www.w3.org/TR/"><abbr title="World Wide Web Consortium">W3C</abbr> technical reports
  13.269 +          index</a> at http://www.w3.org/TR/.</em>
  13.270 +        </p>
  13.271 +
  13.272 +      <p>
  13.273 +        This document represents the early consensus of the group on the scope and features of the proposed
  13.274 +        <abbr title="Application Programming Interface">API</abbr>.
  13.275 +      </p>
  13.276 +
  13.277 +        <p>
  13.278 +          This document was published by the <a href="http://www.w3.org/2009/dap/">Device APIs and Policy Working Group</a> as an Editor's Draft.
  13.279 +
  13.280 +          If you wish to make comments regarding this document, please send them to
  13.281 +          <a href="mailto:public-device-apis@w3.org">public-device-apis@w3.org</a>
  13.282 +          (<a href="mailto:public-device-apis-request@w3.org?subject=subscribe">subscribe</a>,
  13.283 +          <a href="http://lists.w3.org/Archives/Public/public-device-apis/">archives</a>).
  13.284 +
  13.285 +
  13.286 +          All feedback is welcome.
  13.287 +        </p>
  13.288 +
  13.289 +          <p>
  13.290 +            Publication as an Editor's Draft does not imply endorsement by the <abbr title="World Wide Web Consortium">W3C</abbr> Membership.
  13.291 +            This is a draft document and may be updated, replaced or obsoleted by other documents at
  13.292 +            any time. It is inappropriate to cite this document as other than work in progress.
  13.293 +          </p>
  13.294 +
  13.295 +
  13.296 +        <p>
  13.297 +
  13.298 +            This document was produced by a group operating under the
  13.299 +            <a href="http://www.w3.org/Consortium/Patent-Policy-20040205/">5 February 2004 <abbr title="World Wide Web Consortium">W3C</abbr> Patent Policy</a>.
  13.300 +
  13.301 +
  13.302 +
  13.303 +
  13.304 +              <abbr title="World Wide Web Consortium">W3C</abbr> maintains a <a href="http://www.w3.org/2004/01/pp-impl/43696/status" rel="disclosure">public list of any patent disclosures</a>
  13.305 +
  13.306 +            made in connection with the deliverables of the group; that page also includes instructions for
  13.307 +            disclosing a patent. An individual who has actual knowledge of a patent which the individual believes contains
  13.308 +            <a href="http://www.w3.org/Consortium/Patent-Policy-20040205/#def-essential">Essential Claim(s)</a> must disclose the
  13.309 +            information in accordance with <a href="http://www.w3.org/Consortium/Patent-Policy-20040205/#sec-Disclosure">section
  13.310 +            6 of the <abbr title="World Wide Web Consortium">W3C</abbr> Patent Policy</a>.
  13.311 +
  13.312 +
  13.313 +        </p>
  13.314 +
  13.315 +
  13.316 +
  13.317 +
  13.318 +</section><section id="toc"><h2 class="introductory">Table of Contents</h2><ul class="toc"><li class="tocline"><a href="#introduction" class="tocxref"><span class="secno">1. </span>Introduction</a></li><li class="tocline"><a href="#conformance" class="tocxref"><span class="secno">2. </span>Conformance</a><ul class="toc"><li class="tocline"><a href="#dependencies" class="tocxref"><span class="secno">2.1 </span>Dependencies</a></li></ul></li><li class="tocline"><a href="#terminology" class="tocxref"><span class="secno">3. </span>Terminology</a></li><li class="tocline"><a href="#requesting-networked-services" class="tocxref"><span class="secno">4. </span>Requesting networked services</a><ul class="toc"><li class="tocline"><a href="#methods" class="tocxref"><span class="secno">4.1 </span>Methods</a></li><li class="tocline"><a href="#error-handling" class="tocxref"><span class="secno">4.2 </span>Error Handling</a></li></ul></li><li class="tocline"><a href="#obtaining-networked-services" class="tocxref"><span class="secno">5. </span>Obtaining networked services</a><ul class="toc"><li class="tocline"><a href="#attributes" class="tocxref"><span class="secno">5.1 </span>Attributes</a></li><li class="tocline"><a href="#methods-1" class="tocxref"><span class="secno">5.2 </span>Methods</a></li><li class="tocline"><a href="#events" class="tocxref"><span class="secno">5.3 </span>Events</a></li></ul></li><li class="tocline"><a href="#communicating-with-a-networked-service" class="tocxref"><span class="secno">6. </span>Communicating with a networked service</a><ul class="toc"><li class="tocline"><a href="#attributes-1" class="tocxref"><span class="secno">6.1 </span>Attributes</a></li><li class="tocline"><a href="#states" class="tocxref"><span class="secno">6.2 </span>States</a></li><li class="tocline"><a href="#events-1" class="tocxref"><span class="secno">6.3 </span>Events</a></li></ul></li><li class="tocline"><a href="#service-discovery" class="tocxref"><span class="secno">7. </span>Service Discovery</a><ul class="toc"><li class="tocline"><a href="#zeroconf-mdns-dns-sd" class="tocxref"><span class="secno">7.1 </span>Zeroconf (<abbr title="Multicast DNS">mDNS</abbr> + <abbr title="Domain Name System">DNS</abbr>-<abbr title="Service Discovery">SD</abbr>)</a></li><li class="tocline"><a href="#universal-plug-and-play-upnp" class="tocxref"><span class="secno">7.2 </span>Universal Plug-and-Play (<abbr title="Universal Plug-and-Play">UPnP</abbr>)</a></li><li class="tocline"><a href="#network-topology-monitoring" class="tocxref"><span class="secno">7.3 </span>Network Topology Monitoring</a></li></ul></li><li class="tocline"><a href="#garbage-collection" class="tocxref"><span class="secno">8. </span>Garbage collection</a></li><li class="tocline"><a href="#use-cases-and-requirements" class="tocxref"><span class="secno">9. </span>Use Cases and Requirements</a></li><li class="tocline"><a href="#examples" class="tocxref"><span class="secno">A. </span>Examples</a></li><li class="tocline"><a href="#acknowledgements" class="tocxref"><span class="secno">B. </span>Acknowledgements</a></li><li class="tocline"><a href="#references" class="tocxref"><span class="secno">C. </span>References</a><ul class="toc"><li class="tocline"><a href="#normative-references" class="tocxref"><span class="secno">C.1 </span>Normative references</a></li><li class="tocline"><a href="#informative-references" class="tocxref"><span class="secno">C.2 </span>Informative references</a></li></ul></li></ul></section>
  13.319 +
  13.320 +
  13.321 +
  13.322 +    <section class="informative" id="introduction">
  13.323 +      <!--OddPage--><h2><span class="secno">1. </span>Introduction</h2><p><em>This section is non-normative.</em></p>
  13.324 +
  13.325 +      <p>To enable Web pages to connect and communicate with Local-networked Services provided over <abbr title="Hypertext Transfer Protocol">HTTP</abbr>, this specification introduces the
  13.326 +      <a href="#navigatornetworkservice"><code>NavigatorNetworkService</code></a> interface.</p>
  13.327 +
  13.328 +      <p>
  13.329 +         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,
  13.330 +         is expected before the web page is able to interact with any Local-networked Services.
  13.331 +      </p>
  13.332 +
  13.333 +      <p>
  13.334 +         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.
  13.335 +      </p>
  13.336 +
  13.337 +      <p>
  13.338 +         The user agent, having captured all advertised services on the network from the Service Discovery mechanisms included in this recommendation, attempts to match
  13.339 +      the requested service type to a discovered service according to the processing described herein.
  13.340 +      </p>
  13.341 +
  13.342 +      <p>
  13.343 +          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.
  13.344 +          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.
  13.345 +      </p>
  13.346 +
  13.347 +      <p>
  13.348 +         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
  13.349 +         authorized via the provided <abbr title="Application Programming Interface">API</abbr>.
  13.350 +         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
  13.351 +         connected Local-networked Service.
  13.352 +      </p>
  13.353 +
  13.354 +      <div class="example">
  13.355 +       <p>Example of requesting a <abbr title="Domain Name System">DNS</abbr>-<abbr title="Service Discovery">SD</abbr> advertised service:</p>
  13.356 +       <hr>
  13.357 +       <pre class="highlight prettyprint"><span class="kwd">function</span><span class="pln"> showServices</span><span class="pun">(</span><span class="pln"> services </span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
  13.358 +  </span><span class="com">// Show a list of all the services provided to the web page</span><span class="pln">
  13.359 +  </span><span class="kwd">for</span><span class="pun">(</span><span class="kwd">var</span><span class="pln"> i </span><span class="pun">=</span><span class="pln"> </span><span class="lit">0</span><span class="pun">,</span><span class="pln"> l </span><span class="pun">=</span><span class="pln"> services</span><span class="pun">.</span><span class="pln">length</span><span class="pun">;</span><span class="pln"> i </span><span class="pun">&lt;</span><span class="pln"> l</span><span class="pun">;</span><span class="pln"> i</span><span class="pun">++)</span><span class="pln"> console</span><span class="pun">.</span><span class="pln">log</span><span class="pun">(</span><span class="pln"> services</span><span class="pun">[</span><span class="pln">i</span><span class="pun">].</span><span class="pln">name </span><span class="pun">);</span><span class="pln">
  13.360 +</span><span class="pun">}</span><span class="pln">
  13.361 +
  13.362 +navigator</span><span class="pun">.</span><span class="pln">getNetworkServices</span><span class="pun">(</span><span class="str">'zeroconf:_boxee-jsonrpc._tcp'</span><span class="pun">,</span><span class="pln"> showServices</span><span class="pun">);</span></pre>
  13.363 +      </div>
  13.364 +
  13.365 +      <div class="example">
  13.366 +        <p>Example of requesting a <abbr title="Universal Plug-and-Play">UPnP</abbr> advertised service, also handling error conditions:</p>
  13.367 +        <hr>
  13.368 +        <pre class="highlight prettyprint"><span class="kwd">function</span><span class="pln"> showServices</span><span class="pun">(</span><span class="pln"> services </span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
  13.369 +  </span><span class="com">// Show a list of all the services provided to the web page</span><span class="pln">
  13.370 +  </span><span class="kwd">for</span><span class="pun">(</span><span class="kwd">var</span><span class="pln"> i </span><span class="pun">=</span><span class="pln"> </span><span class="lit">0</span><span class="pun">,</span><span class="pln"> l </span><span class="pun">=</span><span class="pln"> services</span><span class="pun">.</span><span class="pln">length</span><span class="pun">;</span><span class="pln"> i </span><span class="pun">&lt;</span><span class="pln"> l</span><span class="pun">;</span><span class="pln"> i</span><span class="pun">++)</span><span class="pln"> console</span><span class="pun">.</span><span class="pln">log</span><span class="pun">(</span><span class="pln"> services</span><span class="pun">[</span><span class="pln">i</span><span class="pun">].</span><span class="pln">name </span><span class="pun">);</span><span class="pln">
  13.371 +</span><span class="pun">}</span><span class="pln">
  13.372 +
  13.373 +</span><span class="kwd">function</span><span class="pln"> error</span><span class="pun">(</span><span class="pln"> e </span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
  13.374 +  console</span><span class="pun">.</span><span class="pln">log</span><span class="pun">(</span><span class="pln"> </span><span class="str">"Error occurred: "</span><span class="pln"> </span><span class="pun">+</span><span class="pln"> e</span><span class="pun">.</span><span class="pln">code </span><span class="pun">);</span><span class="pln">
  13.375 +</span><span class="pun">}</span><span class="pln">
  13.376 +
  13.377 +navigator</span><span class="pun">.</span><span class="pln">getNetworkServices</span><span class="pun">(</span><span class="str">'upnp:urn:schemas-upnp-org:service:ContentDirectory:1'</span><span class="pun">,</span><span class="pln"> showServices</span><span class="pun">,</span><span class="pln"> error</span><span class="pun">);</span></pre>
  13.378 +      </div>
  13.379 +
  13.380 +      <div class="example">
  13.381 +        <p>Example of requesting either a <abbr title="Domain Name System">DNS</abbr>-<abbr title="Service Discovery">SD</abbr> or <abbr title="Universal Plug-and-Play">UPnP</abbr> advertised service:</p>
  13.382 +        <hr>
  13.383 +        <pre class="highlight prettyprint"><span class="kwd">function</span><span class="pln"> showServices</span><span class="pun">(</span><span class="pln"> services </span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
  13.384 +  </span><span class="com">// Show a list of all the services provided to the web page (+ service type)</span><span class="pln">
  13.385 +  </span><span class="kwd">for</span><span class="pun">(</span><span class="kwd">var</span><span class="pln"> i </span><span class="pun">=</span><span class="pln"> </span><span class="lit">0</span><span class="pun">,</span><span class="pln"> l </span><span class="pun">=</span><span class="pln"> services</span><span class="pun">.</span><span class="pln">length</span><span class="pun">;</span><span class="pln"> i </span><span class="pun">&lt;</span><span class="pln"> l</span><span class="pun">;</span><span class="pln"> i</span><span class="pun">++)</span><span class="pln">
  13.386 +     console</span><span class="pun">.</span><span class="pln">log</span><span class="pun">(</span><span class="pln"> services</span><span class="pun">[</span><span class="pln">i</span><span class="pun">].</span><span class="pln">name </span><span class="pun">+</span><span class="pln"> </span><span class="str">'('</span><span class="pln"> </span><span class="pun">+</span><span class="pln"> services</span><span class="pun">[</span><span class="pln">i</span><span class="pun">].</span><span class="pln">type </span><span class="pun">+</span><span class="pln"> </span><span class="str">')'</span><span class="pln"> </span><span class="pun">);</span><span class="pln">
  13.387 +</span><span class="pun">}</span><span class="pln">
  13.388 +
  13.389 +navigator</span><span class="pun">.</span><span class="pln">getNetworkServices</span><span class="pun">([</span><span class="pln">
  13.390 +  </span><span class="str">'zeroconf:_boxee-jsonrpc._tcp'</span><span class="pun">,</span><span class="pln">
  13.391 +  </span><span class="str">'upnp:urn:schemas-upnp-org:service:ContentDirectory:1'</span><span class="pln">
  13.392 +</span><span class="pun">],</span><span class="pln"> showServices</span><span class="pun">);</span></pre>
  13.393 +      </div>
  13.394 +
  13.395 +      <p>For more detailed examples see the <a href="#examples">Examples</a> section.
  13.396 +    </p></section>
  13.397 +
  13.398 +    <section id="conformance"><!--OddPage--><h2><span class="secno">2. </span>Conformance</h2>
  13.399 +<p>
  13.400 +  As well as sections marked as non-normative, all authoring guidelines, diagrams, examples,
  13.401 +  and notes in this specification are non-normative. Everything else in this specification is
  13.402 +  normative.
  13.403 +</p>
  13.404 +<p>
  13.405 +  The key words <em class="rfc2119" title="must">must</em>, <em class="rfc2119" title="must not">must not</em>, <em class="rfc2119" title="required">required</em>, <em class="rfc2119" title="should">should</em>, <em class="rfc2119" title="should not">should not</em>, <em class="rfc2119" title="recommended">recommended</em>, <em class="rfc2119" title="may">may</em>,
  13.406 +  and <em class="rfc2119" title="optional">optional</em> in this specification are to be interpreted as described in [<cite><a class="bibref" href="#bib-RFC2119">RFC2119</a></cite>].
  13.407 +</p>
  13.408 +
  13.409 +
  13.410 +     <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
  13.411 +     meaning of the key word ("must", "should", "may", etc) used in introducing the algorithm.</p>
  13.412 +
  13.413 +     <p>
  13.414 +      Some conformance requirements are phrased as requirements on attributes, methods or objects. Such requirements are to be interpreted as requirements on user agents.
  13.415 +     </p>
  13.416 +
  13.417 +     <p>
  13.418 +      Conformance requirements phrased as algorithms or specific steps may be implemented in any manner, so long as the end result is equivalent. (In particular, the algorithms defined in
  13.419 +      this specification are intended to be easy to follow, and not intended to be performant.)
  13.420 +     </p>
  13.421 +
  13.422 +     <p>
  13.423 +      The only conformance class defined by this specification is a <dfn id="dfn-user-agent">user agent</dfn>.
  13.424 +     </p>
  13.425 +
  13.426 +     <p>
  13.427 +      User agents may 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
  13.428 +      around platform-specific limitations.
  13.429 +     </p>
  13.430 +
  13.431 +     <p>
  13.432 +      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 must act as if
  13.433 +      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
  13.434 +      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
  13.435 +      is insufficient.
  13.436 +     </p>
  13.437 +
  13.438 +      <section id="dependencies">
  13.439 +         <h3><span class="secno">2.1 </span>Dependencies</h3>
  13.440 +
  13.441 +         This specification relies on several other underlying specifications.
  13.442 +
  13.443 +         <dl>
  13.444 +            <dt>HTML</dt>
  13.445 +            <dd>Many fundamental concepts from HTML are used by this specification. [<cite><a class="bibref" href="#bib-HTML5">HTML5</a></cite>]</dd>
  13.446 +            <dt>WebIDL</dt>
  13.447 +            <dd>The IDL blocks in this specification use the semantics of the WebIDL specification. [<cite><a class="bibref" href="#bib-WEBIDL">WEBIDL</a></cite>]</dd>
  13.448 +         </dl>
  13.449 +      </section>
  13.450 +    </section>
  13.451 +
  13.452 +    <section id="terminology">
  13.453 +      <!--OddPage--><h2><span class="secno">3. </span>Terminology</h2>
  13.454 +
  13.455 +      <p>
  13.456 +         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>".
  13.457 +      </p>
  13.458 +
  13.459 +      <p>
  13.460 +         The term DOM is used to refer to the <abbr title="Application Programming Interface">API</abbr> 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
  13.461 +         other <code>Node</code> objects as defined in the DOM Core specifications. [<cite><a class="bibref" href="#bib-DOM4">DOM4</a></cite>]
  13.462 +      </p>
  13.463 +
  13.464 +      <p>
  13.465 +         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.
  13.466 +      </p>
  13.467 +
  13.468 +      <p>
  13.469 +        A <dfn id="dfn-valid-service-type">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.
  13.470 +      </p>
  13.471 +
  13.472 +      <p>
  13.473 +        A <a href="#dfn-valid-service-type" class="internalDFN">valid service type</a> provided in the <code>type</code> attribute of the <code>getNetworkServices()</code> method will be matched against the services currently contained in the <a href="#dfn-list-of-available-service-records" class="internalDFN">list of available service records</a> according to the algorithms defined in this specification.
  13.474 +      </p>
  13.475 +    </section>
  13.476 +
  13.477 +    <section id="requesting-networked-services">
  13.478 +     <!--OddPage--><h2><span class="secno">4. </span>Requesting networked services</h2>
  13.479 +
  13.480 +
  13.481 +<pre class="widl">[Supplemental, NoInterfaceObject]
  13.482 +interface <dfn id="navigatornetworkservice">NavigatorNetworkService</dfn> {
  13.483 +  // Obtain a Local-networked Service
  13.484 +  void <a href="#dom-navigator-getnetworkservices">getNetworkServices</a>( in any type,
  13.485 +                           in <a href="#navigatornetworkservicesuccesscallback">NavigatorNetworkServiceSuccessCallback</a> successCallback,
  13.486 +                           in optional <a href="#navigatornetworkserviceerrorcallback">NavigatorNetworkServiceErrorCallback</a> errorCallback );
  13.487 +};
  13.488 +<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>;
  13.489 +
  13.490 +[Callback=FunctionOnly, NoInterfaceObject]
  13.491 +interface <dfn id="navigatornetworkservicesuccesscallback">NavigatorNetworkServiceSuccessCallback</dfn> {
  13.492 +  void handleEvent( in <a href="#networkservices">NetworkServices</a> services );
  13.493 +};
  13.494 +
  13.495 +[NoInterfaceObject]
  13.496 +interface <dfn id="navigatornetworkserviceerror">NavigatorNetworkServiceError</dfn> {
  13.497 +  const unsigned short <a href="#dom-navigatornetworkserviceerror-permission_denied">PERMISSION_DENIED_ERR</a> = 1;
  13.498 +  const unsigned short <a href="#dom-navigatornetworkserviceerror-unknown_type_prefix">UNKNOWN_TYPE_PREFIX_ERR</a> = 2;
  13.499 +  readonly attribute unsigned short <a href="#dom-navigatornetworkserviceerror-code">code</a>;
  13.500 +};
  13.501 +
  13.502 +[Callback=FunctionOnly, NoInterfaceObject]
  13.503 +interface <dfn id="navigatornetworkserviceerrorcallback">NavigatorNetworkServiceErrorCallback</dfn> {
  13.504 +  void handleEvent( in <a href="#navigatornetworkserviceerror">NavigatorNetworkServiceError</a> error );
  13.505 +};
  13.506 +</pre>
  13.507 +
  13.508 +  <section id="methods">
  13.509 +   <h3><span class="secno">4.1 </span>Methods</h3>
  13.510 +
  13.511 +      <dl class="domintro">
  13.512 +        <dt>
  13.513 +          <var title="">window</var>
  13.514 +           .
  13.515 +          <code title="dom-navigator">
  13.516 +            <a href="http://www.whatwg.org/specs/web-apps/current-work/complete/timers.html#navigator">navigator</a>
  13.517 +          </code>
  13.518 +           .
  13.519 +          <code title="dom-navigator-getNetworkServices">
  13.520 +            <a href="#dom-navigator-getnetworkservices">getNetworkServices</a>
  13.521 +          </code>
  13.522 +          (
  13.523 +          <var title="">type</var>
  13.524 +          ,
  13.525 +          <var title="">successCallback</var>
  13.526 +           [,
  13.527 +          <var title="">errorCallback</var>
  13.528 +           ] )
  13.529 +        </dt>
  13.530 +        <dd>
  13.531 +          <p>Prompts the user to select one or more discovered network services that have advertised support for the requested service type.</p>
  13.532 +          <p>
  13.533 +            The
  13.534 +            <var title="">type</var>
  13.535 +             argument contains one or more <a href="#dfn-valid-service-type" class="internalDFN">valid service type</a> tokens that the web page would like to interact with.
  13.536 +          </p>
  13.537 +          <p>
  13.538 +            If the user accepts, the
  13.539 +            <var title="">successCallback</var>
  13.540 +             is
  13.541 +          invoked, with one or more
  13.542 +            <code>
  13.543 +              <a href="#networkservice"><code>NetworkService</code></a>
  13.544 +            </code>
  13.545 +             objects as
  13.546 +          its argument.
  13.547 +          </p>
  13.548 +          <p>
  13.549 +            If the user declines, the
  13.550 +            <var title="">errorCallback</var>
  13.551 +             (if
  13.552 +          any) is invoked.
  13.553 +          </p>
  13.554 +        </dd>
  13.555 +      </dl>
  13.556 +
  13.557 +       <div>
  13.558 +          <p>
  13.559 +            When the <dfn id="dom-navigator-getnetworkservices" title="dom-navigator-getnetworkservices"><code>getNetworkServices(type, successCallback[, errorCallback])</code></dfn> method is called, the <a href="#dfn-user-agent" class="internalDFN">user agent</a> <em class="rfc2119" title="must">must</em> run the following steps:
  13.560 +          </p>
  13.561 +
  13.562 +          <ol class="rule">
  13.563 +
  13.564 +            <li>
  13.565 +              Let <var>requested control types</var> be initially set to an empty array.
  13.566 +            </li>
  13.567 +
  13.568 +            <li>
  13.569 +               If <var>type</var> is an array consisting of one or more <a href="#dfn-valid-service-type" class="internalDFN">valid service type</a> tokens, then let <var>requested control types</var> by the value of <var>type</var>, removing any non-<a href="#dfn-valid-service-type" class="internalDFN">valid service type</a> tokens from the resulting array.
  13.570 +            </li>
  13.571 +
  13.572 +            <li>
  13.573 +               If <var>type</var> is a string consisting of one <a href="#dfn-valid-service-type" class="internalDFN">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>.
  13.574 +            </li>
  13.575 +
  13.576 +            <li>
  13.577 +               If <var>requested control types</var> is an array that contains at least one or more <a title="valid service type" href="#dfn-valid-service-type" class="internalDFN">valid service type</a> tokens then continue to the step labeled <em>process</em> below. Otherwise, the <a href="#dfn-user-agent" class="internalDFN">user agent</a> <em class="rfc2119" title="must">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
  13.578 +                 <a href="#dom-navigatornetworkserviceerror-code"><code>code</code></a> attribute has the numeric value 2
  13.579 +                  (<a href="#dom-navigatornetworkserviceerror-unknown_type_prefix"><code>UNKNOWN_TYPE_PREFIX_ERR</code></a>) as its argument,
  13.580 +                   abort any remaining steps and return.
  13.581 +            </li>
  13.582 +
  13.583 +            <li>
  13.584 +               <em>Process</em>: Let <var>services found</var> be an empty array.
  13.585 +            </li>
  13.586 +
  13.587 +            <li>
  13.588 +               For each <var>available service</var> in the <a href="#dfn-list-of-available-service-records" class="internalDFN">list of available service records</a> run the following steps:
  13.589 +               <ol class="rule">
  13.590 +                  <li>
  13.591 +                    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.
  13.592 +                  </li>
  13.593 +                  <li>
  13.594 +                     Continue at the next <var>available service</var>.
  13.595 +                  </li>
  13.596 +                  <li>
  13.597 +                     <em>Attach</em>: If <var>matched service</var> is not empty then run the following steps:
  13.598 +
  13.599 +                     <ol class="rule">
  13.600 +                        <li>
  13.601 +                           Let <var>new service object</var> be a new <a href="#networkservice"><code>NetworkService</code></a> object, mapping the parameters of
  13.602 +                     <var>matched service</var> to this new object where possible.
  13.603 +                        </li>
  13.604 +                        <li>
  13.605 +                           Append <var>new service object</var> to the <var>services found</var> array.
  13.606 +                        </li>
  13.607 +                     </ol>
  13.608 +                  </li>
  13.609 +               </ol>
  13.610 +            </li>
  13.611 +
  13.612 +            <li>
  13.613 +               If <var>services found</var> is an empty array, then the <a href="#dfn-user-agent" class="internalDFN">user agent</a> <em class="rfc2119" title="must">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
  13.614 +                 <a href="#dom-navigatornetworkserviceerror-code"><code>code</code></a> attribute has the numeric value 1
  13.615 +                 (<a href="#dom-navigatornetworkserviceerror-permission_denied"><code>PERMISSION_DENIED_ERR</code></a>) as its argument, abort any remaining steps and return.
  13.616 +            </li>
  13.617 +
  13.618 +            <li>
  13.619 +               Return, and run the remaining steps asynchronously.
  13.620 +            </li>
  13.621 +
  13.622 +            <li>
  13.623 +               Optionally, e.g. based on a previously-established user preference, for security reasons, or due to platform limitations, the <a href="#dfn-user-agent" class="internalDFN">user agent</a> <em class="rfc2119" title="may">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
  13.624 +                 <a href="#dom-navigatornetworkserviceerror-code"><code>code</code></a> attribute has the numeric value 1
  13.625 +                 (<a href="#dom-navigatornetworkserviceerror-permission_denied"><code>PERMISSION_DENIED_ERR</code></a>) as its argument, abort any remaining steps and return.
  13.626 +            </li>
  13.627 +
  13.628 +            <li>
  13.629 +                  The <a href="#dfn-user-agent" class="internalDFN">user agent</a> <em class="rfc2119" title="must">must</em> prompt the user in a user-agent-specific manner for permission to provide the
  13.630 +                  <a href="http://www.whatwg.org/specs/web-apps/current-work/complete/browsers.html#entry-script" class="externalDFN">entry script</a>'s
  13.631 +                  <a href="http://www.whatwg.org/specs/web-apps/current-work/complete/origin-0.html#origin" class="externalDFN">origin</a> with an array of
  13.632 +                  <a href="#networkservice"><code>NetworkService</code></a> objects representing the user-authorized subset of <var>services found</var>.
  13.633 +
  13.634 +               <p>
  13.635 +                  If the user grants permission to access one or more networked services then the <a href="#dfn-user-agent" class="internalDFN">user agent</a> <em class="rfc2119" title="should">should</em> include an
  13.636 +                  "ongoing local-network communication" indicator.
  13.637 +               </p>
  13.638 +
  13.639 +               <p>If the user denies permission, then the <a href="#dfn-user-agent" class="internalDFN">user agent</a> <em class="rfc2119" title="must">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
  13.640 +                <a href="#dom-navigatornetworkserviceerror-code"><code>code</code></a> attribute has the numeric value 1
  13.641 +                (<a href="#dom-navigatornetworkserviceerror-permission_denied"><code>PERMISSION_DENIED_ERR</code></a>) as its argument, abort any remaining steps and return.
  13.642 +              </p>
  13.643 +
  13.644 +              <p>
  13.645 +                If the user never responds, this algorithm stalls on this step.
  13.646 +              </p>
  13.647 +
  13.648 +            </li>
  13.649 +
  13.650 +            <li>
  13.651 +               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.
  13.652 +            </li>
  13.653 +
  13.654 +            <li>
  13.655 +               For each Object <var>service</var> in <var>services</var>, run the following substeps:
  13.656 +
  13.657 +               <ol class="rule">
  13.658 +                  <li>
  13.659 +                     Add the <var>service</var>'s <code>url</code> parameter to the <a href="#dfn-entry-script-origin-s-url-whitelist" class="internalDFN">entry script origin's <abbr title="Uniform Resource Locator">URL</abbr> whitelist</a>.
  13.660 +                  </li>
  13.661 +                  <li>
  13.662 +                    If <var>service</var>'s <code>type</code> parameter begins with the DOMString "<code>upnp:</code>" and the <var>service</var>'s <code>eventsUrl</code> parameter is not empty then <a href="#dfn-setup-a-upnp-events-subscription" class="internalDFN">setup a <abbr title="Universal Plug-and-Play">UPnP</abbr> Events Subscription</a> for <var>service</var>.
  13.663 +                  </li>
  13.664 +               </ol>
  13.665 +            </li>
  13.666 +
  13.667 +            <li>
  13.668 +               Let <var>services manager</var> be a new <a href="#networkservices"><code>NetworkServices</code></a> object.
  13.669 +            </li>
  13.670 +
  13.671 +            <li>
  13.672 +               Set <var>services manager</var>'s <a href="#dom-networkservices-servicesavailable"><code>servicesAvailable</code></a> attribute to the length of <var>services</var>.
  13.673 +            </li>
  13.674 +
  13.675 +            <li>
  13.676 +              Store the set of <var>services</var> as <dfn id="current_authorized_services">current authorized services</dfn> internally against the newly created <var>services manager</var> object.
  13.677 +            </li>
  13.678 +
  13.679 +            <li>
  13.680 +               The <a href="#dfn-user-agent" class="internalDFN">user agent</a> <em class="rfc2119" title="must">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
  13.681 +               <var>services manager</var> as its argument.
  13.682 +            </li>
  13.683 +
  13.684 +          </ol>
  13.685 +
  13.686 +          <p>
  13.687 +            The <a href="http://www.whatwg.org/specs/web-apps/current-work/complete/webappapis.html#task-source" class="externalDFN">task source</a> for these
  13.688 +            <a href="http://www.whatwg.org/specs/web-apps/current-work/complete/webappapis.html#concept-task" class="externalDFN">tasks</a> is the
  13.689 +            <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>.
  13.690 +          </p>
  13.691 +
  13.692 +          <p>
  13.693 +            When a <a href="#networkservice"><code>NetworkService</code></a> object is provided to a Web page, the <a href="#dfn-user-agent" class="internalDFN">user agent</a> <em class="rfc2119" title="must">must</em> add the <code>url</code> property
  13.694 +             to the <dfn id="dfn-entry-script-origin-s-url-whitelist">entry script origin's <abbr title="Uniform Resource Locator">URL</abbr> whitelist</dfn>. This list enables the
  13.695 +            Web page to override and initiate cross-site resource requests towards these URLs, and any sub-resources of these URLs, within the current
  13.696 +            <a href="http://www.whatwg.org/specs/web-apps/current-work/complete/browsers.html#entry-script" class="externalDFN">entry script</a>'s
  13.697 +            <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,
  13.698 +            Web Messaging, XMLHttpRequest).
  13.699 +         </p>
  13.700 +
  13.701 +         <p>
  13.702 +            If the user navigates away from the current browsing context, the <a href="#dfn-user-agent" class="internalDFN">user agent</a> <em class="rfc2119" title="must">must</em> remove all previously whitelisted urls from the <a href="#dfn-entry-script-origin-s-url-whitelist" class="internalDFN">entry script origin's <abbr title="Uniform Resource Locator">URL</abbr> whitelist</a>.
  13.703 +            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:
  13.704 +            </p><ul>
  13.705 +              <li>If the current script is reloaded at any point in the same or different window.</li>
  13.706 +              <li>if the current script reinvokes the <a href="#dom-navigator-getnetworkservices"><code>getNetworkServices()</code></a> method at any point in its execution.</li>
  13.707 +              <li>If the user navigates forward or back in their history to reload the current page.</li>
  13.708 +              <li>If a script is running in a different origin.</li>
  13.709 +            </ul>
  13.710 +         <p></p>
  13.711 +
  13.712 +      </div>
  13.713 +      </section>
  13.714 +
  13.715 +      <section id="error-handling">
  13.716 +         <h3><span class="secno">4.2 </span>Error Handling</h3>
  13.717 +
  13.718 +      <dl class="domintro">
  13.719 +        <dt>
  13.720 +          <var title="">error</var>
  13.721 +           .
  13.722 +          <code title="dom-NavigatorNetworkServiceError-code">
  13.723 +            <a href="#dom-navigatornetworkserviceerror-code">code</a>
  13.724 +          </code>
  13.725 +        </dt>
  13.726 +        <dd>
  13.727 +          <p>
  13.728 +            Returns the current error's error code. At the current time, this may be <code>1</code> or <code>2</code>, for which the
  13.729 +            corresponding error constants
  13.730 +            <a href="#dom-navigatornetworkserviceerror-permission_denied"><code>PERMISSION_DENIED_ERR</code></a> and
  13.731 +            <a href="#dom-navigatornetworkserviceerror-unknown_type_prefix"><code>UNKNOWN_TYPE_PREFIX_ERR</code></a> are defined.
  13.732 +          </p>
  13.733 +        </dd>
  13.734 +      </dl>
  13.735 +
  13.736 +         <p>
  13.737 +            The <dfn id="dom-navigatornetworkserviceerror-code" title="dom-navigatornetworkserviceerror-code"><code>code</code></dfn> attribute of a
  13.738 +            <a href="#navigatornetworkserviceerror"><code>NavigatorNetworkServiceError</code></a> object <em class="rfc2119" title="must">must</em> return the code for the error, which will be one of the following:
  13.739 +         </p>
  13.740 +
  13.741 +         <dl>
  13.742 +            <dt>
  13.743 +               <dfn id="dom-navigatornetworkserviceerror-permission_denied" title="dom-navigatornetworkserviceerror-permission_denied"><code>PERMISSION_DENIED_ERR</code></dfn> (numeric value 1)
  13.744 +            </dt>
  13.745 +            <dd>
  13.746 +               The user or user agent denied the page permission to access any services.
  13.747 +            </dd>
  13.748 +            <dt>
  13.749 +               <dfn id="dom-navigatornetworkserviceerror-unknown_type_prefix" title="dom-navigatornetworkserviceerror-unknown_type_prefix"><code>UNKNOWN_TYPE_PREFIX_ERR</code></dfn> (numeric value 2)
  13.750 +            </dt>
  13.751 +            <dd>
  13.752 +               No <a href="#dfn-valid-service-type" class="internalDFN">valid service type</a> tokens were provided in the method invocation.
  13.753 +            </dd>
  13.754 +         </dl>
  13.755 +
  13.756 +      </section>
  13.757 +
  13.758 +      </section>
  13.759 +      <section id="obtaining-networked-services">
  13.760 +      <!--OddPage--><h2><span class="secno">5. </span>Obtaining networked services</h2>
  13.761 +
  13.762 +      <p>
  13.763 +         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.
  13.764 +      </p>
  13.765 +
  13.766 +<pre class="widl">[NoInterfaceObject]
  13.767 +interface <dfn id="networkservices">NetworkServices</dfn> {
  13.768 +  readonly attribute unsigned long    <a href="#dom-networkservices-length">length</a>;
  13.769 +  getter <a href="#networkservice">NetworkService</a> (unsigned long index);
  13.770 +  <a href="#networkservice">NetworkService</a>? <a href="#dom-networkservices-getservicebyid">getServiceById</a>(DOMString id);
  13.771 +
  13.772 +  readonly attribute unsigned long    <a href="#dom-networkservices-servicesavailable">servicesAvailable</a>;
  13.773 +
  13.774 +  // event handler attributes
  13.775 +           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>;
  13.776 +           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>;
  13.777 +
  13.778 +};
  13.779 +
  13.780 +<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>;
  13.781 +</pre>
  13.782 +
  13.783 +      <section id="attributes">
  13.784 +      <h3><span class="secno">5.1 </span>Attributes</h3>
  13.785 +
  13.786 +        <dl class="domintro">
  13.787 +          <dt>
  13.788 +            <code title="dom-networkservices-length">
  13.789 +              <a href="#dom-networkservices-length">length</a>
  13.790 +            </code>
  13.791 +          </dt>
  13.792 +          <dd>
  13.793 +            <p>
  13.794 +              Returns the current number of services in the respective object's <a href="#current_authorized_services" class="internalDFN">current authorized services</a>.
  13.795 +            </p>
  13.796 +          </dd>
  13.797 +          <dt>
  13.798 +            <code title="dom-networkservices-servicesavailable">
  13.799 +              <a href="#dom-networkservices-servicesavailable">servicesAvailable</a>
  13.800 +            </code>
  13.801 +          </dt>
  13.802 +          <dd>
  13.803 +            <p>
  13.804 +              Returns the current number of services matching one of the app-requested <a href="#dfn-valid-service-type" class="internalDFN">valid service type</a> tokens that are actively available within the user's current network.
  13.805 +            </p>
  13.806 +          </dd>
  13.807 +        </dl>
  13.808 +
  13.809 +        <div>
  13.810 +           <p>
  13.811 +              The <dfn id="dom-networkservices-length"><code>length</code></dfn> attribute <em class="rfc2119" title="must">must</em> return the number of services represented in the object's corresponding <a href="#current_authorized_services" class="internalDFN">current authorized services</a> list at the time of getting.
  13.812 +           </p>
  13.813 +
  13.814 +           <p>
  13.815 +              The <dfn id="dom-networkservices-servicesavailable"><code>servicesAvailable</code></dfn> attribute <em class="rfc2119" title="must">must</em> return the number of services available in the
  13.816 +              user's network that match the <a href="#dfn-valid-service-type" class="internalDFN">valid service type</a> that was initially used to create the current <a href="#networkservices"><code>NetworkServices</code></a> object.
  13.817 +           </p>
  13.818 +
  13.819 +           <p>
  13.820 +             When a previously unknown instance of a networked service matching one of the requested <a href="#dfn-valid-service-type">valid service types</a> becomes available on the user's current network, the <a href="#dfn-user-agent" class="internalDFN">user agent</a> <em class="rfc2119" title="must">must</em> increment the <a href="#dom-networkservices-servicesavailable"><code>servicesAvailable</code></a> attribute by <code>1</code> and then
  13.821 +             <a href="http://www.whatwg.org/specs/web-apps/current-work/complete/webappapis.html#queue-a-task" class="externalDFN">queue a task</a>
  13.822 +             to dispatch a newly created event with the name <code>serviceavailable</code> that uses the <code>Event</code> interface, which does
  13.823 +             not bubble, is not cancellable, and has no default action, at the current <a href="#networkservices"><code>NetworkServices</code></a>
  13.824 +             object.
  13.825 +           </p>
  13.826 +
  13.827 +           <p>
  13.828 +             When a previously known instance of a networked service matching one of the requested <a href="#dfn-valid-service-type">valid service types</a> becomes unavailable on the user's current network, the <a href="#dfn-user-agent" class="internalDFN">user agent</a> <em class="rfc2119" title="must">must</em> decrement the <a href="#dom-networkservices-servicesavailable"><code>servicesAvailable</code></a> attribute by <code>1</code> and then
  13.829 +             <a href="http://www.whatwg.org/specs/web-apps/current-work/complete/webappapis.html#queue-a-task" class="externalDFN">queue a task</a>
  13.830 +              to dispatch a newly created event with the name <code>serviceunavailable</code> that uses the <code>Event</code> interface, which does
  13.831 +              not bubble, is not cancellable, and has no default action, at the current <a href="#networkservices"><code>NetworkServices</code></a>
  13.832 +              object.
  13.833 +           </p>
  13.834 +        </div>
  13.835 +
  13.836 +      </section>
  13.837 +
  13.838 +      <section id="methods-1">
  13.839 +      <h3><span class="secno">5.2 </span>Methods</h3>
  13.840 +        <dl class="domintro">
  13.841 +        <dt>
  13.842 +          <code title="networkservices-getter">
  13.843 +            <a href="#networkservices">services</a>
  13.844 +          </code>
  13.845 +          [
  13.846 +          <var title="">index</var>
  13.847 +          ]
  13.848 +        </dt>
  13.849 +        <dd>
  13.850 +          <p>
  13.851 +            Returns the specified <a href="#networkservice"><code>NetworkService</code></a> object.
  13.852 +          </p>
  13.853 +        </dd>
  13.854 +        <dt>
  13.855 +          <code title="networkservices-getter">
  13.856 +            <a href="#networkservices">services</a>
  13.857 +          </code>
  13.858 +          .
  13.859 +          <code title="dom-networkservices-getservicebyid">
  13.860 +            <a href="#dom-networkservices-getservicebyid">getServiceById</a>
  13.861 +          </code>
  13.862 +          (
  13.863 +          <var title="">id</var>
  13.864 +          )
  13.865 +        </dt>
  13.866 +        <dd>
  13.867 +          <p>
  13.868 +            Returns the <a href="#networkservice"><code>NetworkService</code></a> object with the given identifier, or null if no
  13.869 +            service has that identifier.
  13.870 +          </p>
  13.871 +        </dd>
  13.872 +      </dl>
  13.873 +
  13.874 +      <p>
  13.875 +        A <a href="#networkservices"><code>NetworkServices</code></a> object represents the current list of zero or more <a href="#current_authorized_services" class="internalDFN">current authorized services</a>, of which zero or more can be available at a time. Each item in <a href="#current_authorized_services" class="internalDFN">current authorized services</a> is represented by a <a href="#networkservice"><code>NetworkService</code></a> object. The list of <a href="#current_authorized_services" class="internalDFN">current authorized services</a> is <span>immutable</span> meaning that it cannot be modified for the lifetime of a <a href="#networkservices"><code>NetworkServices</code></a> object.
  13.876 +      </p>
  13.877 +
  13.878 +      <div class="note"><div class="note-title"><span>Note</span></div><p class="">
  13.879 +        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. If the <a href="#dfn-user-agent" class="internalDFN">user agent</a> dynamically adds or removes network services for any reason, then the indices of the services in <a href="#current_authorized_services" class="internalDFN">current authorized services</a> will change dynamically. If the set of network services changes entirely, then all the previous services will be removed from <a href="#current_authorized_services" class="internalDFN">current authorized services</a> and replaced with new services.
  13.880 +      </p></div>
  13.881 +
  13.882 +      <p>
  13.883 +        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 <a href="#current_authorized_services" class="internalDFN">current authorized services</a> represented by the respective object minus one, if any services are represented in <a href="#current_authorized_services" class="internalDFN">current authorized services</a>. If a <a href="#networkservices"><code>NetworkServices</code></a> object represents no <a href="#current_authorized_services" class="internalDFN">current authorized services</a>, it has no <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/infrastructure.html#supported-property-indices" class="externalDFN">supported property indices</a>.
  13.884 +      </p>
  13.885 +
  13.886 +      <p>
  13.887 +        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 href="#current_authorized_services" class="internalDFN">current authorized services</a>, the user agent <em class="rfc2119" title="must">must</em> return the <a href="#networkservice"><code>NetworkService</code></a> object that represents the <var>index</var>th service in <a href="#current_authorized_services" class="internalDFN">current authorized services</a>.
  13.888 +      </p>
  13.889 +
  13.890 +      <p>
  13.891 +        The <dfn id="dom-networkservices-getservicebyid"><code>getServiceById(id)</code></dfn> method <em class="rfc2119" title="must">must</em> return the first <a href="#networkservice"><code>NetworkService</code></a> object in <a href="#current_authorized_services" class="internalDFN">current authorized services</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.
  13.892 +        When no services in <a href="#current_authorized_services" class="internalDFN">current authorized services</a> match the given argument, the method <em class="rfc2119" title="must">must</em> return null.
  13.893 +      </p>
  13.894 +
  13.895 +      <p>
  13.896 +         Services available within the local network can connect and disconnect at different times during the execution of a web page. A <a href="#dfn-user-agent" class="internalDFN">user agent</a> can
  13.897 +         inform a web page when the state of networked services matching the requested <a href="#dfn-valid-service-type" class="internalDFN">valid service type</a> change. Web pages can use this information to enable in-page experiences for communicating the state of networked services
  13.898 +         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.
  13.899 +      </p>
  13.900 +
  13.901 +      </section>
  13.902 +
  13.903 +      <section id="events">
  13.904 +      <h3><span class="secno">5.3 </span>Events</h3>
  13.905 +
  13.906 +      <p>
  13.907 +         The following are the event handlers (and their corresponding event handler event types) that must be supported, as IDL attributes, by all objects implementing the <a href="#networkservices"><code>NetworkServices</code></a> interface:
  13.908 +       </p>
  13.909 +
  13.910 +       <table border="1">
  13.911 +        <thead>
  13.912 +          <tr>
  13.913 +            <th>
  13.914 +              <span title="event handlers">Event handler</span>
  13.915 +            </th>
  13.916 +            <th>
  13.917 +              <span>Event handler event type</span>
  13.918 +            </th>
  13.919 +          </tr>
  13.920 +        </thead>
  13.921 +        <tbody>
  13.922 +          <tr>
  13.923 +            <td>
  13.924 +              <dfn id="dom-networkservices-onserviceavailable" title="dom-NetworkServices-onserviceavailable">
  13.925 +                <code>onserviceavailable</code>
  13.926 +              </dfn>
  13.927 +            </td>
  13.928 +            <td>
  13.929 +              <code title="event-serviceavailable">serviceavailable</code>
  13.930 +            </td>
  13.931 +          </tr>
  13.932 +          <tr>
  13.933 +            <td>
  13.934 +              <dfn id="dom-networkservices-onserviceunavailable" title="dom-NetworkServices-onserviceunavailable">
  13.935 +                <code>onserviceunavailable</code>
  13.936 +              </dfn>
  13.937 +            </td>
  13.938 +            <td>
  13.939 +              <code title="event-serviceunavailable">serviceunavailable</code>
  13.940 +            </td>
  13.941 +          </tr>
  13.942 +        </tbody>
  13.943 +      </table>
  13.944 +
  13.945 +      <p>
  13.946 +         Events with an event type of <code>serviceavailable</code> or <code>serviceunavailable</code> defined in this specification are simple <code>Event</code> objects.
  13.947 +      </p>
  13.948 +
  13.949 +      </section>
  13.950 +
  13.951 +    </section>
  13.952 +    <section id="communicating-with-a-networked-service">
  13.953 +    <!--OddPage--><h2><span class="secno">6. </span>Communicating with a networked service</h2>
  13.954 +
  13.955 +<p>
  13.956 +   The <a href="#networkservice"><code>NetworkService</code></a> interface is used to provide a set of connection information for an <abbr title="Hypertext Transfer Protocol">HTTP</abbr> service endpoint and if available, service events, running on a networked device.
  13.957 +</p>
  13.958 +
  13.959 +<pre class="widl">[NoInterfaceObject]
  13.960 +interface <dfn id="networkservice">NetworkService</dfn> {
  13.961 +  readonly attribute DOMString        <a href="#dom-networkservice-id">id</a>;
  13.962 +  readonly attribute DOMString        <a href="#dom-networkservice-name">name</a>;
  13.963 +  readonly attribute DOMString        <a href="#dom-networkservice-type">type</a>;
  13.964 +  readonly attribute DOMString        <a href="#dom-networkservice-url">url</a>;
  13.965 +  readonly attribute DOMString        <a href="#dom-networkservice-config">config</a>;
  13.966 +
  13.967 +  readonly attribute boolean          <a href="#dom-networkservice-online">online</a>;
  13.968 +
  13.969 +  // event handler attributes
  13.970 +           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>;
  13.971 +           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>;
  13.972 +
  13.973 +           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>;
  13.974 +};
  13.975 +
  13.976 +<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>;
  13.977 +</pre>
  13.978 +
  13.979 +<section id="attributes-1">
  13.980 +  <h3><span class="secno">6.1 </span>Attributes</h3>
  13.981 +
  13.982 +      <dl class="domintro">
  13.983 +        <dt>
  13.984 +          <var title="">service</var>
  13.985 +           .
  13.986 +          <code title="dom-networkservice-id">
  13.987 +            <a href="#dom-networkservice-id">id</a>
  13.988 +          </code>
  13.989 +        </dt>
  13.990 +        <dd>
  13.991 +          <p>
  13.992 +            A unique identifier for the given user-selected service instance.
  13.993 +          </p>
  13.994 +        </dd>
  13.995 +        <dt>
  13.996 +          <var title="">service</var>
  13.997 +           .
  13.998 +          <code title="dom-networkservice-name">
  13.999 +            <a href="#dom-networkservice-name">name</a>
 13.1000 +          </code>
 13.1001 +        </dt>
 13.1002 +        <dd>
 13.1003 +          <p>
 13.1004 +            The name of the user-selected service.
 13.1005 +          </p>
 13.1006 +        </dd>
 13.1007 +        <dt>
 13.1008 +          <var title="">service</var>
 13.1009 +           .
 13.1010 +          <code title="dom-networkservice-type">
 13.1011 +            <a href="#dom-networkservice-type">type</a>
 13.1012 +          </code>
 13.1013 +        </dt>
 13.1014 +        <dd>
 13.1015 +          <p>
 13.1016 +            The <a href="#dfn-valid-service-type" class="internalDFN">valid service type</a> token value of the user-selected service.
 13.1017 +          </p>
 13.1018 +        </dd>
 13.1019 +        <dt>
 13.1020 +          <var title="">service</var>
 13.1021 +           .
 13.1022 +          <code title="dom-networkservice-url">
 13.1023 +            <a href="#dom-networkservice-url">url</a>
 13.1024 +          </code>
 13.1025 +        </dt>
 13.1026 +        <dd>
 13.1027 +          <p>
 13.1028 +            The control <abbr title="Uniform Resource Locator">URL</abbr> endpoint (including any required port information) of the user-selected control service that has been added to the <a href="#dfn-entry-script-origin-s-url-whitelist" class="internalDFN">entry script origin's <abbr title="Uniform Resource Locator">URL</abbr> whitelist</a>.
 13.1029 +          </p>
 13.1030 +        </dd>
 13.1031 +        <dt>
 13.1032 +          <var title="">service</var>
 13.1033 +           .
 13.1034 +          <code title="dom-networkservice-config">
 13.1035 +            <a href="#dom-networkservice-config">config</a>
 13.1036 +          </code>
 13.1037 +        </dt>
 13.1038 +        <dd>
 13.1039 +          <p>
 13.1040 +            The configuration information associated with the service depending on the requested service type.
 13.1041 +          </p>
 13.1042 +        </dd>
 13.1043 +      </dl>
 13.1044 +
 13.1045 +          <p>
 13.1046 +            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="rfc2119" title="must">must</em> have the same <a href="#dom-networkservice-id"><code>id</code></a> value.
 13.1047 +         </p>
 13.1048 +
 13.1049 +         <p>
 13.1050 +            The <dfn id="dom-networkservice-name"><code>name</code></dfn> attribute represents a human-readable title for the service.
 13.1051 +         </p>
 13.1052 +
 13.1053 +         <p>
 13.1054 +             The <dfn id="dom-networkservice-type"><code>type</code></dfn> attribute reflects the value of the <a href="#dfn-valid-service-type" class="internalDFN">valid service type</a> of the service.
 13.1055 +          </p>
 13.1056 +
 13.1057 +         <p>
 13.1058 +            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 <abbr title="Uniform Resource Locator">URL</abbr></a> pointing to the root <abbr title="Hypertext Transfer Protocol">HTTP</abbr>
 13.1059 +            endpoint for the service that has been added to the <a href="#dfn-entry-script-origin-s-url-whitelist" class="internalDFN">entry script origin's <abbr title="Uniform Resource Locator">URL</abbr> 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).
 13.1060 +         </p>
 13.1061 +
 13.1062 +         <p>
 13.1063 +            The <dfn id="dom-networkservice-config"><code>config</code></dfn> attribute provides the raw configuration information extracted from the given network service.
 13.1064 +         </p>
 13.1065 +
 13.1066 +      </section>
 13.1067 +
 13.1068 +      <section id="states">
 13.1069 +         <h3><span class="secno">6.2 </span>States</h3>
 13.1070 +
 13.1071 +      <dl class="domintro">
 13.1072 +        <dt>
 13.1073 +          <var title="">service</var>
 13.1074 +           .
 13.1075 +          <code title="dom-networkservice-online">
 13.1076 +            <a href="#dom-networkservice-online">online</a>
 13.1077 +          </code>
 13.1078 +        </dt>
 13.1079 +        <dd>
 13.1080 +          <p>
 13.1081 +            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.
 13.1082 +          </p>
 13.1083 +        </dd>
 13.1084 +      </dl>
 13.1085 +
 13.1086 +      <p>
 13.1087 +        The <dfn id="dom-networkservice-online"><code>online</code></dfn> attribute indicates whether the service is reporting itself as being
 13.1088 +        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="rfc2119" title="must">must</em> default to <code>true</code>.
 13.1089 +      </p>
 13.1090 +
 13.1091 +      </section>
 13.1092 +
 13.1093 +      <section id="events-1">
 13.1094 +         <h3><span class="secno">6.3 </span>Events</h3>
 13.1095 +
 13.1096 +      <p>
 13.1097 +         The following are the event handlers (and their corresponding event handler event types) that must be supported, as IDL attributes, by all objects implementing the
 13.1098 +         <a href="#networkservice"><code>NetworkService</code></a> interface:
 13.1099 +       </p>
 13.1100 +
 13.1101 +       <table border="1">
 13.1102 +        <thead>
 13.1103 +          <tr>
 13.1104 +            <th>
 13.1105 +              <span title="event handlers">Event handler</span>
 13.1106 +            </th>
 13.1107 +            <th>
 13.1108 +              <span>Event handler event type</span>
 13.1109 +            </th>
 13.1110 +          </tr>
 13.1111 +        </thead>
 13.1112 +        <tbody>
 13.1113 +          <tr>
 13.1114 +            <td>
 13.1115 +              <dfn id="dom-networkservice-onnotify" title="dom-NetworkService-onnotify">
 13.1116 +                <code>onnotify</code>
 13.1117 +              </dfn>
 13.1118 +            </td>
 13.1119 +            <td>
 13.1120 +              <code title="event-notify">notify</code>
 13.1121 +            </td>
 13.1122 +          </tr>
 13.1123 +          <tr>
 13.1124 +            <td>
 13.1125 +              <dfn id="dom-networkservice-onserviceonline" title="dom-NetworkService-onserviceonline">
 13.1126 +                <code>onserviceonline</code>
 13.1127 +              </dfn>
 13.1128 +            </td>
 13.1129 +            <td>
 13.1130 +              <code title="event-onserviceonline">serviceonline</code>
 13.1131 +            </td>
 13.1132 +          </tr>
 13.1133 +          <tr>
 13.1134 +            <td>
 13.1135 +              <dfn id="dom-networkservice-onserviceoffline" title="dom-NetworkService-onserviceoffline">
 13.1136 +                <code>onserviceoffline</code>
 13.1137 +              </dfn>
 13.1138 +            </td>
 13.1139 +            <td>
 13.1140 +              <code title="event-onserviceoffline">serviceoffline</code>
 13.1141 +            </td>
 13.1142 +          </tr>
 13.1143 +        </tbody>
 13.1144 +      </table>
 13.1145 +
 13.1146 +      <p>
 13.1147 +         Events with an event type of <code>notify</code>, <code>serviceonline</code> or <code>serviceoffline</code> defined in this specification are simple <code>Event</code> objects.
 13.1148 +      </p>
 13.1149 +
 13.1150 +      </section>
 13.1151 +   </section>
 13.1152 +
 13.1153 +      <section id="service-discovery">
 13.1154 +            <!--OddPage--><h2><span class="secno">7. </span>Service Discovery</h2>
 13.1155 +
 13.1156 +      <p>
 13.1157 +         A <a href="#dfn-user-agent" class="internalDFN">user agent</a> conforming to this specification <em class="rfc2119" title="may">may</em> implement <acronym title="Simple Service Discovery Protocol">SSDP</acronym> [<cite><a class="bibref" href="#bib-UPNP-DEVICEARCH11">UPNP-DEVICEARCH11</a></cite>] and Zeroconf [<cite><a class="bibref" href="#bib-DNS-SD">DNS-SD</a></cite>] + [<cite><a class="bibref" href="#bib-MDNS">MDNS</a></cite>] service discovery mechanisms
 13.1158 +         to enable Web pages to request and connect with <abbr title="Hypertext Transfer Protocol">HTTP</abbr> services running on networked devices, discovered via either mechanism, through this <abbr title="Application Programming Interface">API</abbr>. When a <a href="#dfn-user-agent" class="internalDFN">user agent</a> implements either of these service discovery mechanisms, then it <em class="rfc2119" title="must">must</em> conform to the corresponding algorithms provided in this section of the specification.
 13.1159 +      </p>
 13.1160 +      <p>
 13.1161 +         This section presents how the results of these two service discovery
 13.1162 +         mechanisms will be matched to requested service types and how their properties will be applied to any resulting <a href="#networkservice"><code>NetworkService</code></a> objects.
 13.1163 +      </p>
 13.1164 +
 13.1165 +      <p>
 13.1166 +         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
 13.1167 +         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
 13.1168 +         invocation of this <abbr title="Application Programming Interface">API</abbr> from a Web page).
 13.1169 +      </p>
 13.1170 +
 13.1171 +      <p>
 13.1172 +         The <dfn id="dfn-list-of-available-service-records">list of available service records</dfn> is a single dynamic internal lookup table within user agents that is used to track the current services available in the network at any given time.
 13.1173 +         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
 13.1174 +         services changes. Each record contained within this table contains the attributes: <code>id</code>, <code>name</code>, <code>type</code>, <code>url</code> and <code>config</code>.
 13.1175 +      </p>
 13.1176 +
 13.1177 +            <section id="zeroconf-mdns-dns-sd">
 13.1178 +         <h3><span class="secno">7.1 </span>Zeroconf (<abbr title="Multicast DNS">mDNS</abbr> + <abbr title="Domain Name System">DNS</abbr>-<abbr title="Service Discovery">SD</abbr>)</h3>
 13.1179 +
 13.1180 +         <p>
 13.1181 +            For each <abbr title="Domain Name System">DNS</abbr> response received from a user-agent-initiated Multicast <abbr title="Domain Name System">DNS</abbr> 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
 13.1182 +   domain [<cite><a class="bibref" href="#bib-MDNS">MDNS</a></cite>], the <a href="#dfn-user-agent" class="internalDFN">user agent</a> <em class="rfc2119" title="must">must</em> run the following steps:
 13.1183 +         </p>
 13.1184 +
 13.1185 +         <ol class="rule">
 13.1186 +
 13.1187 +            <li>Let <var>service <abbr title="Multicast DNS">mDNS</abbr> responses</var> be an array of <abbr title="DNS Pointer Record">PTR</abbr> records received by issuing a Multicast <abbr title="Domain Name System">DNS</abbr> Browse for <abbr title="DNS Pointer Record">PTR</abbr> records with the name of the current discovered service type.</li>
 13.1188 +
 13.1189 +            <li>For each Object <var>service <abbr title="Multicast DNS">mDNS</abbr> response</var> in <var>service <abbr title="Multicast DNS">mDNS</abbr> responses</var>, run the following steps:
 13.1190 +               <ol>
 13.1191 +
 13.1192 +                  <li>
 13.1193 +                     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>.
 13.1194 +                  </li>
 13.1195 +
 13.1196 +                  <li>
 13.1197 +                     Set <var>network service record</var>'s <code>id</code> property to the value of the full <abbr title="DNS Pointer Record">PTR</abbr> Service Instance Name [<cite><a class="bibref" href="#bib-MDNS">MDNS</a></cite>].
 13.1198 +                  </li>
 13.1199 +
 13.1200 +                  <li>
 13.1201 +                     Set <var>network service record</var>'s <code>name</code> property to the value of the <abbr title="DNS Pointer Record">PTR</abbr> Service Instance Name's <var>Instance</var> component [<cite><a class="bibref" href="#bib-MDNS">MDNS</a></cite>].
 13.1202 +                  </li>
 13.1203 +
 13.1204 +                  <li>
 13.1205 +                     Set <var>network service record</var>'s <code>type</code> property to the concatenation of the string <code>zeroconf:</code> followed by the value of the <abbr title="DNS Pointer Record">PTR</abbr> Service Instance Name's <var>Service</var> component [<cite><a class="bibref" href="#bib-MDNS">MDNS</a></cite>].
 13.1206 +                  </li>
 13.1207 +
 13.1208 +                  <li>
 13.1209 +                     Set <var>network service record</var>'s <code>url</code> property to the resolvable Service <abbr title="Uniform Resource Locator">URL</abbr> obtained from performing an <abbr title="Domain Name System">DNS</abbr>-<abbr title="Service Discovery">SD</abbr> Lookup [<cite><a class="bibref" href="#bib-DNS-SD">DNS-SD</a></cite>] of the current service from the <abbr title="DNS Pointer Record">PTR</abbr> record provided [<cite><a class="bibref" href="#bib-MDNS">MDNS</a></cite>].
 13.1210 +                  </li>
 13.1211 +
 13.1212 +                  <li>
 13.1213 +                     Set <var>network service record</var>'s <code>config</code> property to the string value of the contents of the first <abbr title="Domain Name System">DNS</abbr>-<abbr title="Service Discovery">SD</abbr> TXT record associated with the <var>service <abbr title="Multicast DNS">mDNS</abbr> response</var> as defined in [<cite><a class="bibref" href="#bib-DNS-SD">DNS-SD</a></cite>].
 13.1214 +                  </li>
 13.1215 +
 13.1216 +                  <li>
 13.1217 +                     For each Object <var>existing service record</var> in the current <a href="#dfn-list-of-available-service-records" class="internalDFN">list of available service records</a>, run the following sub-steps:
 13.1218 +                     <ol class="rule">
 13.1219 +
 13.1220 +                       <li>
 13.1221 +                        If the <var>existing service record</var>'s <code>id</code> property matches the value of the <var>network service record</var>'s <code>id</code>, then set the
 13.1222 +                        value of <var>existing service record</var> in the current <a href="#dfn-list-of-available-service-records" class="internalDFN">list of available service records</a>  to the value of the
 13.1223 +                        <var>network service record</var> and skip the next step.
 13.1224 +                       </li>
 13.1225 +                     </ol>
 13.1226 +                  </li>
 13.1227 +
 13.1228 +                  <li>
 13.1229 +                     Add <var>network service record</var> to the <a href="#dfn-list-of-available-service-records" class="internalDFN">list of available service records</a>.
 13.1230 +                  </li>
 13.1231 +
 13.1232 +                  <li>
 13.1233 +                     For each non-garbage collected <a href="#networkservice"><code>NetworkService</code></a> object run the following steps:
 13.1234 +
 13.1235 +                     <ol class="rule">
 13.1236 +                        <li>
 13.1237 +                           If the <a href="#networkservice"><code>NetworkService</code></a> object's <code>type</code> attribute does not equal the
 13.1238 +                           current <a>network service record</a>'s <code>type</code> property then continue at the next available active
 13.1239 +                           <a href="#networkservice"><code>NetworkService</code></a> object.
 13.1240 +                        </li>
 13.1241 +                        <li>
 13.1242 +                           Increment the <a href="#dom-networkservices-servicesavailable"><code>servicesAvailable</code></a> attribute of the <a href="#networkservices"><code>NetworkServices</code></a> object by <code>1</code>.
 13.1243 +                        </li>
 13.1244 +                        <li>
 13.1245 +                          <a href="http://www.whatwg.org/specs/web-apps/current-work/complete/webappapis.html#queue-a-task" class="externalDFN">Queue a task</a>
 13.1246 +                           to dispatch a newly created event with the name <code>serviceavailable</code> that uses the <code>Event</code> interface, which does not bubble, is not cancellable, and has no default action, at the current
 13.1247 +                            <a href="#networkservices"><code>NetworkServices</code></a> object.
 13.1248 +                        </li>
 13.1249 +                        <li>
 13.1250 +                          <a href="http://www.whatwg.org/specs/web-apps/current-work/complete/webappapis.html#queue-a-task" class="externalDFN">Queue a task</a>
 13.1251 +                           to dispatch a newly created event with the name <code>serviceonline</code> that uses the <code>Event</code> interface, which does not bubble, is not cancellable, and has no default action, at the current
 13.1252 +                           <a href="#networkservice"><code>NetworkService</code></a> object.
 13.1253 +                        </li>
 13.1254 +                     </ol>
 13.1255 +                  </li>
 13.1256 +            </ol>
 13.1257 +           </li>
 13.1258 +         </ol>
 13.1259 +
 13.1260 +      </section>
 13.1261 +
 13.1262 +      <section id="universal-plug-and-play-upnp">
 13.1263 +         <h3><span class="secno">7.2 </span>Universal Plug-and-Play (<abbr title="Universal Plug-and-Play">UPnP</abbr>)</h3>
 13.1264 +
 13.1265 +         <p>
 13.1266 +            For each <acronym title="Simple Service Discovery Protocol">SSDP</acronym> Presence Announcement [<cite><a class="bibref" href="#bib-UPNP-DEVICEARCH11">UPNP-DEVICEARCH11</a></cite>] - a <abbr title="Hypertext Transfer Protocol">HTTP</abbr> NOTIFY request - received from a user-agent-initiated <acronym title="Simple Service Discovery Protocol">SSDP</acronym> Discovery Request [<cite><a class="bibref" href="#bib-UPNP-DEVICEARCH11">UPNP-DEVICEARCH11</a></cite>], the <a href="#dfn-user-agent" class="internalDFN">user agent</a> <em class="rfc2119" title="must">must</em> run the following steps:
 13.1267 +         </p>
 13.1268 +
 13.1269 +         <ol class="rule">
 13.1270 +            <li>
 13.1271 +               Let <var>ssdp device</var> be an Object with a property for each <abbr title="Hypertext Transfer Protocol">HTTP</abbr> header received in the received <acronym title="Simple Service Discovery Protocol">SSDP</acronym> Presence Announcement, with each key being the name of a <abbr title="Hypertext Transfer Protocol">HTTP</abbr> header and its
 13.1272 +               value being that <abbr title="Hypertext Transfer Protocol">HTTP</abbr> header's accompanying value.
 13.1273 +            </li>
 13.1274 +
 13.1275 +            <li>
 13.1276 +               If <var>ssdp device</var> does not contain at least one <var>NTS</var>, <var>USN</var> and <var>Location</var> parameter, then the <a href="#dfn-user-agent" class="internalDFN">user agent</a> <em class="rfc2119" title="must">must</em> abort these steps.
 13.1277 +            </li>
 13.1278 +
 13.1279 +            <li>
 13.1280 +               If the first occurrence of <var>NTS</var> has a value other than <code>ssdp:alive</code>, then continue to the step labeled <var>update service monitor</var> below.
 13.1281 +            </li>
 13.1282 +
 13.1283 +            <li>
 13.1284 +               Let <var>root device descriptor file</var> contain the contents of the file located at the <abbr title="Uniform Resource Locator">URL</abbr> provided in the first occurrence of <var>Location</var> obtained according to the rules
 13.1285 +               defined in the section 'Retrieving a description using <abbr title="Hypertext Transfer Protocol">HTTP</abbr>' [<cite><a class="bibref" href="#bib-UPNP-DEVICEARCH11">UPNP-DEVICEARCH11</a></cite>].
 13.1286 +            </li>
 13.1287 +
 13.1288 +            <li>
 13.1289 +               If <var>root device descriptor file</var> is empty, then the <a href="#dfn-user-agent" class="internalDFN">user agent</a> <em class="rfc2119" title="must">must</em> abort these steps.
 13.1290 +            </li>
 13.1291 +
 13.1292 +            <li>
 13.1293 +               Let <var>advertised services</var> be a <a>list of all advertised services</a> obtained from the <var>root device descriptor file</var> containing all sub-nodes of the <code>serviceList</code> node as described in
 13.1294 +               the section 'Device Description' [<cite><a class="bibref" href="#bib-UPNP-DEVICEARCH11">UPNP-DEVICEARCH11</a></cite>].
 13.1295 +            </li>
 13.1296 +
 13.1297 +            <li>
 13.1298 +               For each Object <var>advertised service</var> in <var>advertised services</var> run the following steps:
 13.1299 +               <ol class="rule">
 13.1300 +
 13.1301 +                  <li>
 13.1302 +                     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>eventsUrl</code>, <code>config</code>.
 13.1303 +                  </li>
 13.1304 +
 13.1305 +                  <li>
 13.1306 +                     Set <var>network service record</var>'s <code>id</code> property to the string value of the first occurrence of <var>ssdp device</var>'s <var>USN</var> parameter.
 13.1307 +                  </li>
 13.1308 +
 13.1309 +                  <li>
 13.1310 +                     Set <var>network service record</var>'s <code>name</code> property to the string value of the first occurrence of the <var>service</var>'s <code>serviceId</code> property.
 13.1311 +                  </li>
 13.1312 +
 13.1313 +                  <li>
 13.1314 +                     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>service</var>'s <code>serviceType</code> property.
 13.1315 +                  </li>
 13.1316 +
 13.1317 +                  <li>
 13.1318 +                     Set <var>network service record</var>'s <code>url</code> property to the string value of the first occurrence of the <var>service</var>'s <code>controlURL</code> property.
 13.1319 +                  </li>
 13.1320 +
 13.1321 +                  <li>
 13.1322 +                     Set <var>network service record</var>'s <code>config</code> property to the string value of the first occurrence of the <var>device</var> property.
 13.1323 +                  </li>
 13.1324 +
 13.1325 +                  <li>
 13.1326 +                     If <var>service</var>'s <code>eventSubURL</code> property is empty, then continue to the step labeled <em>register</em> below.
 13.1327 +                  </li>
 13.1328 +
 13.1329 +                  <li>
 13.1330 +                     Set <var>network service record</var>'s <code>eventsUrl</code> property to the string value of the first occurrence of the <var>service</var>'s <code>eventSubURL</code> property.
 13.1331 +                  </li>
 13.1332 +
 13.1333 +                  <li>
 13.1334 +                     <em>Register</em>: For each Object <var>existing service record</var> in the current <a href="#dfn-list-of-available-service-records" class="internalDFN">list of available service records</a>, run the following sub-steps:
 13.1335 +                     <ol class="rule">
 13.1336 +
 13.1337 +                       <li>
 13.1338 +                        If the <var>existing service record</var>'s <var>id</var> property matches the value of the first occurrence of <var>USN</var> and the
 13.1339 +                        <var>existing service record</var>'s <code>type</code> property matches the value of <var>network service record</var>'s <code>type</code>, then set the
 13.1340 +                        value of <var>existing service record</var> in the current <a href="#dfn-list-of-available-service-records" class="internalDFN">list of available service records</a>  to the value of the
 13.1341 +                        <var>network service record</var> and skip the next step.
 13.1342 +                       </li>
 13.1343 +                     </ol>
 13.1344 +                  </li>
 13.1345 +
 13.1346 +                  <li>
 13.1347 +                     Add <var>network service record</var> to the <a href="#dfn-list-of-available-service-records" class="internalDFN">list of available service records</a>.
 13.1348 +                  </li>
 13.1349 +
 13.1350 +               </ol>
 13.1351 +            </li>
 13.1352 +            <li>
 13.1353 +               <em>Update Service Monitor</em>: For each non-garbage collected <a href="#networkservice"><code>NetworkService</code></a> object run the following steps:
 13.1354 +
 13.1355 +               <ol class="rule">
 13.1356 +                  <li>
 13.1357 +                     If this <a href="#networkservice"><code>NetworkService</code></a> object's <code>type</code> attribute does not equal the
 13.1358 +                     current <a>network service record</a>'s <code>type</code> property then continue at the next available active
 13.1359 +                     <a href="#networkservice"><code>NetworkService</code></a> object.
 13.1360 +                  </li>
 13.1361 +                  <li>
 13.1362 +                     If the <var>announcement type</var> equals <code>ssdp:alive</code> then increment the <a href="#dom-networkservices-servicesavailable"><code>servicesAvailable</code></a> attribute of the <a href="#networkservices"><code>NetworkServices</code></a>
 13.1363 +                     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>
 13.1364 +                      to dispatch a newly created event with the name <code>serviceavailable</code> that uses the <code>Event</code> interface, which does not bubble, is not cancellable, and has no default action, at the current
 13.1365 +                      <a href="#networkservice"><code>NetworkServices</code></a> object. Otherwise, decrement the <a href="#dom-networkservices-servicesavailable"><code>servicesAvailable</code></a> attribute of the <a href="#networkservices"><code>NetworkServices</code></a>
 13.1366 +                     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>
 13.1367 +                       to dispatch a newly created event with the name <code>serviceunavailable</code> that uses the <code>Event</code> interface, which does not bubble, is not cancellable, and has no default action, at the current
 13.1368 +                       <a href="#networkservice"><code>NetworkServices</code></a> object.
 13.1369 +                  </li>
 13.1370 +                  <li>
 13.1371 +                     If the <var>announcement type</var> equals <code>ssdp:alive</code> then <a href="http://www.whatwg.org/specs/web-apps/current-work/complete/webappapis.html#queue-a-task" class="externalDFN">queue a task</a>
 13.1372 +                      to dispatch a newly created event with the name <code>serviceonline</code> that uses the <code>Event</code> interface, which does not bubble, is not cancellable, and has no default action, at the current
 13.1373 +                      <a href="#networkservice"><code>NetworkService</code></a> object. Otherwise, <a href="http://www.whatwg.org/specs/web-apps/current-work/complete/webappapis.html#queue-a-task" class="externalDFN">queue a task</a>
 13.1374 +                       to dispatch a newly created event with the name <code>serviceoffline</code> that uses the <code>Event</code> interface, which does not bubble, is not cancellable, and has no default action, at the current
 13.1375 +                       <a href="#networkservice"><code>NetworkService</code></a> object.
 13.1376 +                  </li>
 13.1377 +               </ol>
 13.1378 +            </li>
 13.1379 +         </ol>
 13.1380 +
 13.1381 +         <p>
 13.1382 +            A <dfn id="dfn-user-agent-generated-callback-url">user-agent generated callback url</dfn> is a Local-network accessible <abbr title="Uniform Resource Locator">URL</abbr> endpoint that a <a href="#dfn-user-agent" class="internalDFN">user agent</a> must generate and maintain for receiving <abbr title="Hypertext Transfer Protocol">HTTP</abbr> NOTIFY requests from <abbr title="Universal Plug-and-Play">UPnP</abbr> Event sources.
 13.1383 +         </p>
 13.1384 +
 13.1385 +         <p>When the <a href="#dfn-user-agent" class="internalDFN">user agent</a> is to <dfn id="dfn-setup-a-upnp-events-subscription">setup a <abbr title="Universal Plug-and-Play">UPnP</abbr> Events Subscription</dfn>, it is to run the following steps with the current <var>network service record</var> object:</p>
 13.1386 +
 13.1387 +         <ol class="rule">
 13.1388 +            <li>
 13.1389 +               If <var>network service record</var>'s <code>eventsUrl</code> property is empty then the <a href="#dfn-user-agent" class="internalDFN">user agent</a> <em class="rfc2119" title="must">must</em> abort these steps.
 13.1390 +            </li>
 13.1391 +
 13.1392 +            <li>
 13.1393 +               Let <var>callback <abbr title="Uniform Resource Locator">URL</abbr></var> be the value of creating a new <a href="#dfn-user-agent-generated-callback-url" class="internalDFN">user-agent generated callback url</a>.
 13.1394 +            </li>
 13.1395 +
 13.1396 +            <li>
 13.1397 +               Send a <abbr title="Hypertext Transfer Protocol">HTTP</abbr> SUBSCRIBE request with a <em>NT</em> header with a string value of <code>upnp:event</code>, a <em>TIMEOUT</em> header with an integer value ofƒ
 13.1398 +               <code>86400</code> and a <em>CALLBACK</em> header
 13.1399 +               with a string value of <var>callback <abbr title="Uniform Resource Locator">URL</abbr></var> towards the <var>network service record</var>'s <code>eventsUrl</code> property.
 13.1400 +            </li>
 13.1401 +
 13.1402 +            <li>
 13.1403 +               If a non-200 OK response is received from the <abbr title="Hypertext Transfer Protocol">HTTP</abbr> SUBSCRIBE request then the <a href="#dfn-user-agent" class="internalDFN">user agent</a> <em class="rfc2119" title="must">must</em> abort these steps.
 13.1404 +            </li>
 13.1405 +
 13.1406 +            <li>
 13.1407 +               On receiving a valid 200 OK response, run the following steps:
 13.1408 +
 13.1409 +               <ol class="rule">
 13.1410 +                  <li>
 13.1411 +                     Let <var>callback ID</var> equal the string value of the first included <em>SID</em> header, if it exists.
 13.1412 +                  </li>
 13.1413 +                  <li>
 13.1414 +                     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, if it exists.
 13.1415 +                  </li>
 13.1416 +                  <li>
 13.1417 +                     Run the following steps aynchronously and continue to the step labeled <em>listen</em> below.
 13.1418 +                  </li>
 13.1419 +                  <li>
 13.1420 +                     <em>Refresh Subscription</em>: Run the following steps at a set interval (X) within the <a href="#dfn-user-agent" class="internalDFN">user agent</a>:
 13.1421 +
 13.1422 +                     <ol class="rule">
 13.1423 +                        <li>
 13.1424 +                           Let <var>current date</var> equal the current UTC date.
 13.1425 +                        </li>
 13.1426 +                        <li>
 13.1427 +                           If <var>current date</var> is less than the <var>timeout date</var> then continue to the step labeled <em>refresh subscription</em> above.
 13.1428 +                        </li>
 13.1429 +                        <li>
 13.1430 +                           Send a <abbr title="Hypertext Transfer Protocol">HTTP</abbr> SUBSCRIBE request with a <em>SID</em> header with the string value of <var>callback ID</var> and a <em>TIMEOUT</em> header
 13.1431 +                           with an integer value of <code>86400</code> towards the <var>network service record</var>'s <code>eventsUrl</code> property.
 13.1432 +                        </li>
 13.1433 +                        <li>
 13.1434 +                           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 <abbr title="Hypertext Transfer Protocol">HTTP</abbr>
 13.1435 +                           responses should cause the <a href="#dfn-user-agent" class="internalDFN">user agent</a> to continue from the step labeled <em>refresh subscription</em> above.
 13.1436 +                        </li>
 13.1437 +                     </ol>
 13.1438 +
 13.1439 +                  </li>
 13.1440 +
 13.1441 +                  <li>
 13.1442 +                     <em>Listen</em>: For each <abbr title="Hypertext Transfer Protocol">HTTP</abbr> NOTIFY request received at the <var>callback <abbr title="Uniform Resource Locator">URL</abbr></var> the <a href="#dfn-user-agent" class="internalDFN">user agent</a> is to run the following steps:
 13.1443 +
 13.1444 +                     <ol class="rule">
 13.1445 +                        <li>
 13.1446 +                           Let <var>content clone</var> be the result of obtaining the message body of the <abbr title="Hypertext Transfer Protocol">HTTP</abbr> NOTIFY request. If <var>content clone</var> is empty, then the <a href="#dfn-user-agent" class="internalDFN">user agent</a> <em class="rfc2119" title="must">must</em> abort these steps.
 13.1447 +                        </li>
 13.1448 +                        <li>
 13.1449 +                          Let <var>notification event</var> be a new simple event that uses the <code>Event</code> interface with the name <code>notify</code>,
 13.1450 +                           which does not bubble, is not cancellable, and has no default action.
 13.1451 +                        </li>
 13.1452 +                        <li>
 13.1453 +                           Let the <code>data</code> attribute of <var>notification event</var> have the DOMString value of <var>content clone</var>.
 13.1454 +                        </li>
 13.1455 +                        <li>
 13.1456 +                           <a href="http://www.whatwg.org/specs/web-apps/current-work/complete/webappapis.html#queue-a-task" class="externalDFN">Queue a task</a> to
 13.1457 +                            dispatch <var>notification event</var> at the current <a href="#networkservice" class="internalDFN"><code>NetworkService</code></a> object.
 13.1458 +                        </li>
 13.1459 +                     </ol>
 13.1460 +                  </li>
 13.1461 +
 13.1462 +               </ol>
 13.1463 +
 13.1464 +            </li>
 13.1465 +         </ol>
 13.1466 +
 13.1467 +         </section>
 13.1468 +
 13.1469 +         <section id="network-topology-monitoring">
 13.1470 +            <h3><span class="secno">7.3 </span>Network Topology Monitoring</h3>
 13.1471 +
 13.1472 +                  <div>
 13.1473 +                     <p>
 13.1474 +                        When the <a href="#dfn-user-agent" class="internalDFN">user agent</a> detects that the user has dropped from their connected network, then it <em class="rfc2119" title="must">must</em> run the following steps:
 13.1475 +                     </p>
 13.1476 +
 13.1477 +                     <ol class="rule">
 13.1478 +                        <li>
 13.1479 +                           Flush all entries from the <a href="#dfn-list-of-available-service-records" class="internalDFN">list of available service records</a>.
 13.1480 +                        </li>
 13.1481 +                        <li>
 13.1482 +                           For each <a href="#networkservice"><code>NetworkService</code></a> object currently active in the <a href="#dfn-user-agent" class="internalDFN">user agent</a> perform the following steps:
 13.1483 +
 13.1484 +                           <ol class="rule">
 13.1485 +                              <li>
 13.1486 +                                 Set the <a href="#dom-networkservice-online"><code>online</code></a> attribute to <code>false</code>.
 13.1487 +                              </li>
 13.1488 +                              <li>
 13.1489 +                                 <a href="http://www.whatwg.org/specs/web-apps/current-work/complete/webappapis.html#queue-a-task" class="externalDFN">Queue a task</a>
 13.1490 +                                                      to dispatch a newly created event with the name <code>serviceoffline</code> that uses the <code>Event</code> interface, which does not bubble, is not cancellable, and has no default action, at the current
 13.1491 +                                                      <a href="#networkservice"><code>NetworkService</code></a> object.
 13.1492 +                           </li></ol>
 13.1493 +                        </li>
 13.1494 +                        <li>
 13.1495 +                          For each <a href="#networkservices"><code>NetworkServices</code></a> object currently active in the <a href="#dfn-user-agent" class="internalDFN">user agent</a> perform the following steps:
 13.1496 +
 13.1497 +                          <ol class="rule">
 13.1498 +                            <li>
 13.1499 +                              Let <var>number of available services</var> equal the value of <a href="#networkservices"><code>NetworkServices</code></a>'s <a href="#dom-networkservices-servicesavailable"><code>servicesAvailable</code></a> attribute.
 13.1500 +                            </li>
 13.1501 +                            <li>
 13.1502 +                              Set the <a href="#networkservices"><code>NetworkServices</code></a>'s <a href="#dom-networkservices-servicesavailable"><code>servicesAvailable</code></a> attribute to zero (<code>0</code>).
 13.1503 +                            </li>
 13.1504 +                            <li>
 13.1505 +                              For each <var>available service</var> in <var>number of available services</var> the <a href="#dfn-user-agent" class="internalDFN">user agent</a> <em class="rfc2119" title="must">must</em> fire a new simple event with the name <code>serviceunavailable</code> that has no default action, does not bubble and is not cancellable, at the current <a href="#networkservices"><code>NetworkServices</code></a> object.
 13.1506 +                            </li>
 13.1507 +                          </ol>
 13.1508 +                        </li>
 13.1509 +
 13.1510 +                     </ol>
 13.1511 +
 13.1512 +                     <p>
 13.1513 +                        When the <a href="#dfn-user-agent" class="internalDFN">user agent</a> detects that the user has connected to a new network, then it <em class="rfc2119" title="should">should</em> run the following steps:
 13.1514 +                     </p>
 13.1515 +
 13.1516 +                     <ol class="rule">
 13.1517 +                        <li>
 13.1518 +                           Re-issue an <abbr title="Multicast DNS">mDNS</abbr> search and <acronym title="Simple Service Discovery Protocol">SSDP</acronym> discovery search using all of the <a href="#dfn-valid-service-type" class="internalDFN">valid service type</a> tokens initially provided to all active <a href="#networkservices"><code>NetworkServices</code></a> objects and handle all discovery responses according to the processing defined in <a href="#service-discovery">Section 7: Service Discovery</a>.
 13.1519 +                        </li>
 13.1520 +                     </ol>
 13.1521 +                  </div>
 13.1522 +         </section>
 13.1523 +      </section>
 13.1524 +
 13.1525 +   <section id="garbage-collection">
 13.1526 +      <!--OddPage--><h2><span class="secno">8. </span>Garbage collection</h2>
 13.1527 +
 13.1528 +      <p>
 13.1529 +         A <a href="#networkservice" class="internalDFN"><code>NetworkService</code></a> object containing a <code>url</code> parameter currently in the <a href="#dfn-entry-script-origin-s-url-whitelist" class="internalDFN">entry script origin's <abbr title="Uniform Resource Locator">URL</abbr> whitelist</a> <em class="rfc2119" title="must not">must not</em> be garbage collected.
 13.1530 +      </p>
 13.1531 +
 13.1532 +      <p>
 13.1533 +         Only when the user navigates away from the current browsing context can <a href="#networkservice" class="internalDFN"><code>NetworkService</code></a> objects be garbage-collected and records in the <a href="#dfn-entry-script-origin-s-url-whitelist" class="internalDFN">entry script origin's <abbr title="Uniform Resource Locator">URL</abbr> whitelist</a> be removed.
 13.1534 +      </p>
 13.1535 +
 13.1536 +   </section>
 13.1537 +
 13.1538 +
 13.1539 +    <section id="use-cases-and-requirements">
 13.1540 +      <!--OddPage--><h2><span class="secno">9. </span>Use Cases and Requirements</h2>
 13.1541 +
 13.1542 +      <p>This section covers what the requirements are for this <abbr title="Application Programming Interface">API</abbr>, as well as illustrates some use cases.</p>
 13.1543 +
 13.1544 +      <ul class="rule">
 13.1545 +         <li>
 13.1546 +            Once a user has given permission, user agents should provide the ability for Web pages to communicate directly with a Local-networked Service.
 13.1547 +            <ul class="rule">
 13.1548 +               <li>
 13.1549 +                  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
 13.1550 +                  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
 13.1551 +                  application logic to communicate. Local devices providing the request service types are discovered and presented to the user for authorization. The user selects one
 13.1552 +                  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
 13.1553 +                  the user-authorized Local-networked services.
 13.1554 +               </li>
 13.1555 +            </ul>
 13.1556 +         </li>
 13.1557 +
 13.1558 +         <li>
 13.1559 +           Web pages should be able to communicate with Local-networked Services using the messaging channel supported by those Devices.
 13.1560 +           <ul class="rule">
 13.1561 +            <li>
 13.1562 +               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
 13.1563 +               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
 13.1564 +               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.
 13.1565 +            </li>
 13.1566 +           </ul>
 13.1567 +         </li>
 13.1568 +
 13.1569 +         <li>
 13.1570 +           Web pages should be able to communicate with Local-networked Services using the messaging format supported by those Devices.
 13.1571 +           <ul class="rule">
 13.1572 +            <li>
 13.1573 +               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
 13.1574 +               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
 13.1575 +               between <abbr title="Universal Plug-and-Play">UPnP</abbr>, 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
 13.1576 +               Server in the messaging format supported by that Device, which, in this example is a simple key/value pair text format.
 13.1577 +            </li>
 13.1578 +           </ul>
 13.1579 +         </li>
 13.1580 +
 13.1581 +         <li>
 13.1582 +           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.
 13.1583 +           <ul class="rule">
 13.1584 +            <li>
 13.1585 +               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
 13.1586 +               within the network, should not be accessible to the current Web page.
 13.1587 +            </li>
 13.1588 +           </ul>
 13.1589 +         </li>
 13.1590 +
 13.1591 +         <li>
 13.1592 +           A user should be able to share one or more Local-networked Services based on a particular service type request from a Web page.
 13.1593 +           <ul class="rule">
 13.1594 +            <li>
 13.1595 +               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
 13.1596 +               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
 13.1597 +               actions on to one or more of the authorized Local-networked Services.
 13.1598 +            </li>
 13.1599 +           </ul>
 13.1600 +         </li>
 13.1601 +
 13.1602 +         <li>
 13.1603 +           User agents should provide an <abbr title="Application Programming Interface">API</abbr> 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
 13.1604 +           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
 13.1605 +           these APIs occur silently without user intervention.
 13.1606 +         </li>
 13.1607 +      </ul>
 13.1608 +    </section>
 13.1609 +
 13.1610 +          <section class="informative appendix" id="examples">
 13.1611 +             <!--OddPage--><h2><span class="secno">A. </span>Examples</h2><p><em>This section is non-normative.</em></p>
 13.1612 +
 13.1613 +           <div class="example">
 13.1614 +            <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.
 13.1615 +            </p><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>
 13.1616 +            <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>
 13.1617 +            <hr>
 13.1618 +            <pre class="highlight prettyprint"><span class="tag">&lt;input</span><span class="pln"> </span><span class="atn">type</span><span class="pun">=</span><span class="atv">"button"</span><span class="pln"> </span><span class="atn">value</span><span class="pun">=</span><span class="atv">"Start"</span><span class="pln"> </span><span class="atn">onclick</span><span class="pun">=</span><span class="atv">"</span><span class="pln">start</span><span class="pun">()</span><span class="atv">"</span><span class="pln"> </span><span class="atn">id</span><span class="pun">=</span><span class="atv">"startBtn"</span><span class="tag">/&gt;</span><span class="pln">
 13.1619 +</span><span class="tag">&lt;div</span><span class="pln"> </span><span class="atn">id</span><span class="pun">=</span><span class="atv">"debugconsole"</span><span class="tag">&gt;&lt;/div&gt;</span><span class="pln">
 13.1620 +
 13.1621 +</span><span class="tag">&lt;script&gt;</span><span class="pln">
 13.1622 + </span><span class="kwd">var</span><span class="pln"> startBtn </span><span class="pun">=</span><span class="pln"> document</span><span class="pun">.</span><span class="pln">getElementById</span><span class="pun">(</span><span class="str">'startBtn'</span><span class="pun">),</span><span class="pln">
 13.1623 +     debug </span><span class="pun">=</span><span class="pln"> document</span><span class="pun">.</span><span class="pln">getElementById</span><span class="pun">(</span><span class="str">'debugconsole'</span><span class="pun">);</span><span class="pln">
 13.1624 +
 13.1625 + </span><span class="kwd">function</span><span class="pln"> start</span><span class="pun">()</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
 13.1626 +   </span><span class="kwd">if</span><span class="pun">(</span><span class="pln">navigator</span><span class="pun">.</span><span class="pln">getNetworkServices</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
 13.1627 +      navigator</span><span class="pun">.</span><span class="pln">getNetworkServices</span><span class="pun">(</span><span class="str">'zeroconf:_xbmc-jsonrpc._tcp'</span><span class="pun">,</span><span class="pln"> gotXBMCService</span><span class="pun">,</span><span class="pln"> error</span><span class="pun">);</span><span class="pln">
 13.1628 +      startBtn</span><span class="pun">.</span><span class="pln">disabled </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">true</span><span class="pun">;</span><span class="pln">
 13.1629 +   </span><span class="pun">}</span><span class="pln"> </span><span class="kwd">else</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
 13.1630 +      debug</span><span class="pun">.</span><span class="pln">innerHTML </span><span class="pun">+=</span><span class="pln"> </span><span class="str">"&lt;br&gt;Service Discovery not supported!"</span><span class="pun">;</span><span class="pln">
 13.1631 +   </span><span class="pun">}</span><span class="pln">
 13.1632 + </span><span class="pun">}</span><span class="pln">
 13.1633 +
 13.1634 + </span><span class="kwd">function</span><span class="pln"> gotXBMCService</span><span class="pun">(</span><span class="pln">services</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
 13.1635 +
 13.1636 +</span><span class="com">// Listen for service disconnect messages</span><span class="pln">
 13.1637 +
 13.1638 +   services</span><span class="pun">[</span><span class="lit">0</span><span class="pun">].</span><span class="pln">addEventListener</span><span class="pun">(</span><span class="str">'serviceoffline'</span><span class="pun">,</span><span class="pln"> </span><span class="kwd">function</span><span class="pln"> </span><span class="pun">(</span><span class="pln"> e </span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
 13.1639 +       debug</span><span class="pun">.</span><span class="pln">innerHTML </span><span class="pun">+=</span><span class="pln"> </span><span class="str">"&lt;br&gt;"</span><span class="pln"> </span><span class="pun">+</span><span class="pln"> services</span><span class="pun">[</span><span class="lit">0</span><span class="pun">].</span><span class="pln">name </span><span class="pun">+</span><span class="pln"> </span><span class="str">" disconnected."</span><span class="pun">;</span><span class="pln">
 13.1640 +       startBtn</span><span class="pun">.</span><span class="pln">disabled </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">false</span><span class="pun">;</span><span class="pln">
 13.1641 +   </span><span class="pun">},</span><span class="pln"> </span><span class="kwd">false</span><span class="pun">);</span><span class="pln">
 13.1642 +
 13.1643 +</span><span class="com">// Send a service message to get albums list (and process the service response)</span><span class="pln">
 13.1644 +
 13.1645 +   </span><span class="kwd">var</span><span class="pln"> svcXhr </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">new</span><span class="pln"> </span><span class="typ">XMLHttpRequest</span><span class="pun">();</span><span class="pln">
 13.1646 +   svcXhr</span><span class="pun">.</span><span class="pln">open</span><span class="pun">(</span><span class="str">"POST"</span><span class="pun">,</span><span class="pln"> services</span><span class="pun">[</span><span class="lit">0</span><span class="pun">].</span><span class="pln">url </span><span class="pun">+</span><span class="pln"> </span><span class="str">"/getAlbums"</span><span class="pun">);</span><span class="pln"> </span><span class="com">// services[0].url and its subresources have been</span><span class="pln">
 13.1647 +                                                        </span><span class="com">// whitelisted for cross-site XHR use in this</span><span class="pln">
 13.1648 +                                                        </span><span class="com">// current browsing context.</span><span class="pln">
 13.1649 +
 13.1650 +   svcXhr</span><span class="pun">.</span><span class="pln">setRequestHeader</span><span class="pun">(</span><span class="str">'Content-Type'</span><span class="pun">,</span><span class="pln"> </span><span class="str">'application/json-rpc'</span><span class="pun">);</span><span class="pln">
 13.1651 +
 13.1652 +   svcXhr</span><span class="pun">.</span><span class="pln">addEventListener</span><span class="pun">(</span><span class="str">'readystatechange'</span><span class="pun">,</span><span class="pln"> </span><span class="kwd">function</span><span class="pln"> </span><span class="pun">(</span><span class="pln"> response </span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
 13.1653 +     </span><span class="kwd">if</span><span class="pun">(</span><span class="pln"> response</span><span class="pun">.</span><span class="pln">readyState </span><span class="pun">!=</span><span class="pln"> </span><span class="lit">4</span><span class="pln"> </span><span class="pun">||</span><span class="pln"> response</span><span class="pun">.</span><span class="pln">status </span><span class="pun">!=</span><span class="pln"> </span><span class="lit">200</span><span class="pln"> </span><span class="pun">)</span><span class="pln">
 13.1654 +        </span><span class="kwd">return</span><span class="pun">;</span><span class="pln">
 13.1655 +     debug</span><span class="pun">.</span><span class="pln">innerHTML </span><span class="pun">+=</span><span class="pln"> </span><span class="str">"&lt;br&gt;"</span><span class="pln"> </span><span class="pun">+</span><span class="pln"> services</span><span class="pun">[</span><span class="lit">0</span><span class="pun">].</span><span class="pln">name </span><span class="pun">+</span><span class="pln"> </span><span class="str">" response received: "</span><span class="pun">;</span><span class="pln">
 13.1656 +     debug</span><span class="pun">.</span><span class="pln">textContent </span><span class="pun">+=</span><span class="pln"> JSON</span><span class="pun">.</span><span class="pln">parse</span><span class="pun">(</span><span class="pln">response</span><span class="pun">.</span><span class="pln">responseText</span><span class="pun">);</span><span class="pln">
 13.1657 +   </span><span class="pun">},</span><span class="pln"> </span><span class="kwd">false</span><span class="pun">);</span><span class="pln">
 13.1658 +
 13.1659 +   </span><span class="kwd">var</span><span class="pln"> svcMsg </span><span class="pun">=</span><span class="pln"> </span><span class="pun">[</span><span class="pln">
 13.1660 +     </span><span class="pun">{</span><span class="pln"> </span><span class="str">"jsonrpc"</span><span class="pun">:</span><span class="pln"> </span><span class="str">"2.0"</span><span class="pun">,</span><span class="pln"> </span><span class="str">"method"</span><span class="pun">:</span><span class="pln"> </span><span class="str">"AudioLibrary.GetAlbums"</span><span class="pun">,</span><span class="pln"> </span><span class="str">"params"</span><span class="pun">:</span><span class="pln"> </span><span class="pun">{</span><span class="pln"> </span><span class="str">"genreid"</span><span class="pun">:</span><span class="pln"> </span><span class="pun">-</span><span class="lit">1</span><span class="pun">,</span><span class="pln">
 13.1661 +         </span><span class="str">"artistid"</span><span class="pun">:</span><span class="pln"> </span><span class="pun">-</span><span class="lit">1</span><span class="pun">,</span><span class="pln"> </span><span class="str">"start"</span><span class="pun">:</span><span class="pln"> </span><span class="pun">-</span><span class="lit">1</span><span class="pun">,</span><span class="pln"> </span><span class="str">"end"</span><span class="pun">:</span><span class="pln"> </span><span class="pun">-</span><span class="lit">1</span><span class="pln"> </span><span class="pun">},</span><span class="pln"> </span><span class="str">"id"</span><span class="pun">:</span><span class="pln"> </span><span class="str">"1"</span><span class="pln"> </span><span class="pun">}</span><span class="pln">
 13.1662 +   </span><span class="pun">];</span><span class="pln">
 13.1663 +
 13.1664 +   svcXhr</span><span class="pun">.</span><span class="pln">send</span><span class="pun">(</span><span class="pln">JSON</span><span class="pun">.</span><span class="pln">stringify</span><span class="pun">(</span><span class="pln">svcMsg</span><span class="pun">));</span><span class="pln">
 13.1665 +   debug</span><span class="pun">.</span><span class="pln">innerHTML </span><span class="pun">+=</span><span class="pln"> </span><span class="str">"&lt;br&gt;"</span><span class="pln"> </span><span class="pun">+</span><span class="pln"> services</span><span class="pun">[</span><span class="lit">0</span><span class="pun">].</span><span class="pln">name </span><span class="pun">+</span><span class="pln"> </span><span class="str">" request sent: "</span><span class="pun">;</span><span class="pln">
 13.1666 +   debug</span><span class="pun">.</span><span class="pln">textContent </span><span class="pun">+=</span><span class="pln"> JSON</span><span class="pun">.</span><span class="pln">stringify</span><span class="pun">(</span><span class="pln">svcMsg</span><span class="pun">);</span><span class="pln">
 13.1667 +
 13.1668 + </span><span class="pun">}</span><span class="pln">
 13.1669 +
 13.1670 + </span><span class="kwd">function</span><span class="pln"> error</span><span class="pun">(</span><span class="pln"> err </span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
 13.1671 +   debug</span><span class="pun">.</span><span class="pln">innerHTML </span><span class="pun">+=</span><span class="pln"> </span><span class="str">"&lt;br&gt;An error occurred obtaining a local network service."</span><span class="pun">;</span><span class="pln">
 13.1672 +   startBtn</span><span class="pun">.</span><span class="pln">disabled </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">false</span><span class="pun">;</span><span class="pln">
 13.1673 + </span><span class="pun">}</span><span class="pln">
 13.1674 +</span><span class="tag">&lt;/script&gt;</span></pre>
 13.1675 +           </div>
 13.1676 +
 13.1677 +           <div class="example">
 13.1678 +            <p>
 13.1679 +             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
 13.1680 +             based on the service type requested. The user may also select multiple network services matching the selected service type.
 13.1681 +             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
 13.1682 +             (<var>urn:schemas-upnp-org:service:RenderingControl:1</var>).
 13.1683 +             <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.
 13.1684 +            </p>
 13.1685 +            <hr>
 13.1686 +            <pre class="highlight prettyprint"><span class="tag">&lt;select</span><span class="pln"> </span><span class="atn">name</span><span class="pun">=</span><span class="atv">"make"</span><span class="pln"> </span><span class="atn">id</span><span class="pun">=</span><span class="atv">"make"</span><span class="tag">&gt;</span><span class="pln">
 13.1687 +  </span><span class="tag">&lt;option</span><span class="pln"> </span><span class="atn">selected</span><span class="pun">=</span><span class="atv">"selected"</span><span class="pln"> </span><span class="atn">disabled</span><span class="pun">=</span><span class="atv">"disabled"</span><span class="tag">&gt;</span><span class="pln">Select make</span><span class="tag">&lt;/option&gt;</span><span class="pln">
 13.1688 +  </span><span class="tag">&lt;option&gt;</span><span class="pln">Sony</span><span class="tag">&lt;/option&gt;</span><span class="pln">
 13.1689 +  </span><span class="tag">&lt;option&gt;</span><span class="pln">Philips</span><span class="tag">&lt;/option&gt;</span><span class="pln">
 13.1690 +  </span><span class="tag">&lt;option&gt;</span><span class="pln">Alba</span><span class="tag">&lt;/option&gt;</span><span class="pln">
 13.1691 +</span><span class="tag">&lt;/select&gt;</span><span class="pln">
 13.1692 +</span><span class="tag">&lt;select</span><span class="pln"> </span><span class="atn">name</span><span class="pun">=</span><span class="atv">"model"</span><span class="pln"> </span><span class="atn">id</span><span class="pun">=</span><span class="atv">"model"</span><span class="tag">&gt;&lt;/select&gt;</span><span class="pln">
 13.1693 +</span><span class="tag">&lt;div</span><span class="pln"> </span><span class="atn">id</span><span class="pun">=</span><span class="atv">"debugconsole"</span><span class="tag">&gt;&lt;/div&gt;</span><span class="pln">
 13.1694 +
 13.1695 +</span><span class="tag">&lt;script&gt;</span><span class="pln">
 13.1696 +  </span><span class="kwd">var</span><span class="pln"> debug </span><span class="pun">=</span><span class="pln"> document</span><span class="pun">.</span><span class="pln">getElementById</span><span class="pun">(</span><span class="str">'debugconsole'</span><span class="pun">);</span><span class="pln">
 13.1697 +
 13.1698 +  </span><span class="kwd">var</span><span class="pln"> models </span><span class="pun">=</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
 13.1699 +    </span><span class="str">"Sony"</span><span class="pun">:</span><span class="pln"> </span><span class="pun">[</span><span class="pln">
 13.1700 +      </span><span class="pun">{</span><span class="str">"name"</span><span class="pun">:</span><span class="pln"> </span><span class="str">"Bravia TV S1000"</span><span class="pun">,</span><span class="pln"> </span><span class="str">"type"</span><span class="pun">:</span><span class="pln"> </span><span class="str">"upnp"</span><span class="pun">,</span><span class="pln"> </span><span class="str">"service"</span><span class="pun">:</span><span class="pln"> </span><span class="str">"urn:schemas-upnp-org:service:RenderingControl:1"</span><span class="pln"> </span><span class="pun">},</span><span class="pln">
 13.1701 +      </span><span class="pun">{</span><span class="str">"name"</span><span class="pun">:</span><span class="pln"> </span><span class="str">"Bravia TV S2000"</span><span class="pun">,</span><span class="pln"> </span><span class="str">"type"</span><span class="pun">:</span><span class="pln"> </span><span class="str">"zeroconf"</span><span class="pun">,</span><span class="pln"> </span><span class="str">"service"</span><span class="pun">:</span><span class="pln"> </span><span class="str">"_mediarenderer._http._tcp"</span><span class="pln"> </span><span class="pun">},</span><span class="pln">
 13.1702 +      </span><span class="pun">{</span><span class="str">"name"</span><span class="pun">:</span><span class="pln"> </span><span class="str">"HiFi WD10"</span><span class="pun">,</span><span class="pln"> </span><span class="str">"type"</span><span class="pun">:</span><span class="pln"> </span><span class="str">"upnp"</span><span class="pun">,</span><span class="pln"> </span><span class="str">"service"</span><span class="pun">:</span><span class="pln"> </span><span class="str">"urn:schemas-upnp-org:service:RenderingControl:1"</span><span class="pln"> </span><span class="pun">}</span><span class="pln">
 13.1703 +    </span><span class="pun">],</span><span class="pln">
 13.1704 +    </span><span class="str">"Philips"</span><span class="pun">:</span><span class="pln"> </span><span class="pun">[</span><span class="pln"> </span><span class="com">/* ... */</span><span class="pln"> </span><span class="pun">],</span><span class="pln">
 13.1705 +    </span><span class="str">"Alba"</span><span class="pun">:</span><span class="pln"> </span><span class="pun">[</span><span class="pln"> </span><span class="com">/* ... */</span><span class="pln"> </span><span class="pun">]</span><span class="pln">
 13.1706 +  </span><span class="pun">};</span><span class="pln">
 13.1707 +
 13.1708 +  </span><span class="kwd">var</span><span class="pln"> makeEl </span><span class="pun">=</span><span class="pln"> document</span><span class="pun">.</span><span class="pln">getElementById</span><span class="pun">(</span><span class="str">"make"</span><span class="pun">),</span><span class="pln">
 13.1709 +      modelEl </span><span class="pun">=</span><span class="pln"> document</span><span class="pun">.</span><span class="pln">getElementById</span><span class="pun">(</span><span class="str">"model"</span><span class="pun">);</span><span class="pln">
 13.1710 +
 13.1711 +  makeEl</span><span class="pun">.</span><span class="pln">addEventListener</span><span class="pun">(</span><span class="str">'change'</span><span class="pun">,</span><span class="pln"> </span><span class="kwd">function</span><span class="pun">()</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
 13.1712 +    modelEl</span><span class="pun">.</span><span class="pln">innerHTML </span><span class="pun">=</span><span class="pln"> </span><span class="str">""</span><span class="pun">;</span><span class="pln"> </span><span class="com">// reset</span><span class="pln">
 13.1713 +    </span><span class="kwd">var</span><span class="pln"> defaultOption </span><span class="pun">=</span><span class="pln"> document</span><span class="pun">.</span><span class="pln">createElement</span><span class="pun">(</span><span class="str">"option"</span><span class="pun">);</span><span class="pln">
 13.1714 +    defaultOption</span><span class="pun">.</span><span class="pln">textContent </span><span class="pun">=</span><span class="pln"> </span><span class="str">"Select model"</span><span class="pun">;</span><span class="pln">
 13.1715 +    defaultOption</span><span class="pun">.</span><span class="pln">setAttribute</span><span class="pun">(</span><span class="str">"disabled"</span><span class="pun">,</span><span class="pln"> </span><span class="str">"disabled"</span><span class="pun">);</span><span class="pln">
 13.1716 +    defaultOption</span><span class="pun">.</span><span class="pln">setAttribute</span><span class="pun">(</span><span class="str">"selected"</span><span class="pun">,</span><span class="pln"> </span><span class="str">"selected"</span><span class="pun">);</span><span class="pln">
 13.1717 +    modelEl</span><span class="pun">.</span><span class="pln">appendChild</span><span class="pun">(</span><span class="pln">defaultOption</span><span class="pun">);</span><span class="pln">
 13.1718 +    </span><span class="kwd">for</span><span class="pun">(</span><span class="kwd">var</span><span class="pln"> i </span><span class="pun">=</span><span class="pln"> </span><span class="lit">0</span><span class="pun">,</span><span class="pln"> l </span><span class="pun">=</span><span class="pln"> models</span><span class="pun">[</span><span class="pln">makeEl</span><span class="pun">.</span><span class="pln">value</span><span class="pun">].</span><span class="pln">length</span><span class="pun">;</span><span class="pln"> i </span><span class="pun">&lt;</span><span class="pln"> l</span><span class="pun">;</span><span class="pln"> i</span><span class="pun">++)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
 13.1719 +      </span><span class="kwd">var</span><span class="pln"> option </span><span class="pun">=</span><span class="pln"> document</span><span class="pun">.</span><span class="pln">createElement</span><span class="pun">(</span><span class="str">"option"</span><span class="pun">);</span><span class="pln">
 13.1720 +      option</span><span class="pun">.</span><span class="pln">textContent </span><span class="pun">=</span><span class="pln"> models</span><span class="pun">[</span><span class="pln">makeEl</span><span class="pun">.</span><span class="pln">value</span><span class="pun">][</span><span class="pln">i</span><span class="pun">][</span><span class="str">"name"</span><span class="pun">];</span><span class="pln">
 13.1721 +      option</span><span class="pun">.</span><span class="pln">setAttribute</span><span class="pun">(</span><span class="str">"value"</span><span class="pun">,</span><span class="pln"> models</span><span class="pun">[</span><span class="pln">makeEl</span><span class="pun">.</span><span class="pln">value</span><span class="pun">][</span><span class="pln">i</span><span class="pun">][</span><span class="str">"type"</span><span class="pun">]</span><span class="pln"> </span><span class="pun">+</span><span class="pln"> </span><span class="str">":"</span><span class="pln"> </span><span class="pun">+</span><span class="pln"> models</span><span class="pun">[</span><span class="pln">makeEl</span><span class="pun">.</span><span class="pln">value</span><span class="pun">][</span><span class="pln">i</span><span class="pun">][</span><span class="str">"service"</span><span class="pun">]);</span><span class="pln">
 13.1722 +      modelEl</span><span class="pun">.</span><span class="pln">appendChild</span><span class="pun">(</span><span class="pln">option</span><span class="pun">);</span><span class="pln">
 13.1723 +    </span><span class="pun">}</span><span class="pln">
 13.1724 +  </span><span class="pun">},</span><span class="pln"> </span><span class="kwd">false</span><span class="pun">);</span><span class="pln">
 13.1725 +
 13.1726 +  modelEl</span><span class="pun">.</span><span class="pln">addEventListener</span><span class="pun">(</span><span class="str">'change'</span><span class="pun">,</span><span class="pln"> </span><span class="kwd">function</span><span class="pun">()</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
 13.1727 +    </span><span class="kwd">if</span><span class="pun">(</span><span class="pln">navigator</span><span class="pun">.</span><span class="pln">getNetworkServices </span><span class="pun">&amp;&amp;</span><span class="pln">
 13.1728 +         modelEl</span><span class="pun">.</span><span class="pln">value </span><span class="pun">==</span><span class="pln"> </span><span class="str">"upnp:urn:schemas-upnp-org:service:RenderingControl:1"</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
 13.1729 +      navigator</span><span class="pun">.</span><span class="pln">getNetworkServices</span><span class="pun">(</span><span class="pln">modelEl</span><span class="pun">.</span><span class="pln">value</span><span class="pun">,</span><span class="pln"> successCallback</span><span class="pun">,</span><span class="pln"> errorCallback</span><span class="pun">);</span><span class="pln">
 13.1730 +    </span><span class="pun">}</span><span class="pln"> </span><span class="kwd">else</span><span class="pln"> </span><span class="kwd">if</span><span class="pln"> </span><span class="pun">(</span><span class="pln">modelEl</span><span class="pun">.</span><span class="pln">value </span><span class="pun">==</span><span class="pln"> </span><span class="str">"zeroconf:_mediarenderer._http._tcp"</span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
 13.1731 +      debug</span><span class="pun">.</span><span class="pln">innerHTML </span><span class="pun">+=</span><span class="pln"> </span><span class="str">"&lt;br&gt;Service type is not implemented by this application."</span><span class="pun">;</span><span class="pln">
 13.1732 +    </span><span class="pun">}</span><span class="pln"> </span><span class="kwd">else</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
 13.1733 +      debug</span><span class="pun">.</span><span class="pln">innerHTML </span><span class="pun">+=</span><span class="pln"> </span><span class="str">"&lt;br&gt;Service Discovery is not supported!"</span><span class="pun">;</span><span class="pln">
 13.1734 +    </span><span class="pun">}</span><span class="pln">
 13.1735 +  </span><span class="pun">},</span><span class="pln"> </span><span class="kwd">false</span><span class="pun">);</span><span class="pln">
 13.1736 +</span><span class="tag">&lt;/script&gt;</span><span class="pln">
 13.1737 +
 13.1738 +</span><span class="tag">&lt;script&gt;</span><span class="pln">
 13.1739 +  </span><span class="kwd">function</span><span class="pln"> successCallback</span><span class="pun">(</span><span class="pln"> services </span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
 13.1740 +
 13.1741 +  </span><span class="com">// Listen for service push notification messages</span><span class="pln">
 13.1742 +
 13.1743 +    services</span><span class="pun">[</span><span class="lit">0</span><span class="pun">].</span><span class="pln">addEventListener</span><span class="pun">(</span><span class="str">'notify'</span><span class="pun">,</span><span class="pln"> </span><span class="kwd">function</span><span class="pln"> </span><span class="pun">(</span><span class="pln"> msg </span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
 13.1744 +         debug</span><span class="pun">.</span><span class="pln">innerHTML </span><span class="pun">+=</span><span class="pln"> </span><span class="str">"&lt;br&gt;"</span><span class="pln"> </span><span class="pun">+</span><span class="pln"> services</span><span class="pun">[</span><span class="lit">0</span><span class="pun">].</span><span class="pln">name </span><span class="pun">+</span><span class="pln"> </span><span class="str">" event received: "</span><span class="pun">;</span><span class="pln">
 13.1745 +         debug</span><span class="pun">.</span><span class="pln">textContent </span><span class="pun">+=</span><span class="pln"> msg</span><span class="pun">.</span><span class="pln">data</span><span class="pun">;</span><span class="pln">
 13.1746 +    </span><span class="pun">},</span><span class="pln"> </span><span class="kwd">false</span><span class="pun">);</span><span class="pln">
 13.1747 +
 13.1748 + </span><span class="com">// Send a control signal to mute the service audio</span><span class="pln">
 13.1749 +
 13.1750 +    </span><span class="kwd">var</span><span class="pln"> svcXhr </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">new</span><span class="pln"> </span><span class="typ">XMLHttpRequest</span><span class="pun">();</span><span class="pln">
 13.1751 +    svcXhr</span><span class="pun">.</span><span class="pln">open</span><span class="pun">(</span><span class="str">"POST"</span><span class="pun">,</span><span class="pln"> services</span><span class="pun">[</span><span class="lit">0</span><span class="pun">].</span><span class="pln">url</span><span class="pun">);</span><span class="pln"> </span><span class="com">// services[0].url and its</span><span class="pln">
 13.1752 +                                          </span><span class="com">// subresources have been whitelisted for</span><span class="pln">
 13.1753 +                                          </span><span class="com">// cross-site XHR use in this current</span><span class="pln">
 13.1754 +                                          </span><span class="com">// browsing context.</span><span class="pln">
 13.1755 +
 13.1756 +    svcXhr</span><span class="pun">.</span><span class="pln">setRequestHeader</span><span class="pun">(</span><span class="str">'SOAPAction'</span><span class="pun">,</span><span class="pln"> </span><span class="str">'urn:schemas-upnp-org:service:RenderingControl:1#SetMute'</span><span class="pun">);</span><span class="pln">
 13.1757 +    svcXhr</span><span class="pun">.</span><span class="pln">setRequestHeader</span><span class="pun">(</span><span class="str">'Content-Type'</span><span class="pun">,</span><span class="pln"> </span><span class="str">'text/xml; charset="utf-8";'</span><span class="pun">);</span><span class="pln">
 13.1758 +
 13.1759 +    svcXhr</span><span class="pun">.</span><span class="pln">onreadystatechange </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">function</span><span class="pln"> </span><span class="pun">(</span><span class="pln"> response </span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
 13.1760 +      </span><span class="kwd">if</span><span class="pun">(</span><span class="pln"> response</span><span class="pun">.</span><span class="pln">readyState </span><span class="pun">!=</span><span class="pln"> </span><span class="lit">4</span><span class="pln"> </span><span class="pun">||</span><span class="pln"> response</span><span class="pun">.</span><span class="pln">status </span><span class="pun">!=</span><span class="pln"> </span><span class="lit">200</span><span class="pln"> </span><span class="pun">)</span><span class="pln">
 13.1761 +        </span><span class="kwd">return</span><span class="pun">;</span><span class="pln">
 13.1762 +      debug</span><span class="pun">.</span><span class="pln">innerHTML </span><span class="pun">+=</span><span class="pln"> </span><span class="str">"&lt;br&gt;"</span><span class="pln"> </span><span class="pun">+</span><span class="pln"> services</span><span class="pun">[</span><span class="lit">0</span><span class="pun">].</span><span class="pln">name </span><span class="pun">+</span><span class="pln"> </span><span class="str">" response received: "</span><span class="pun">;</span><span class="pln">
 13.1763 +      debug</span><span class="pun">.</span><span class="pln">textContent </span><span class="pun">+=</span><span class="pln"> response</span><span class="pun">.</span><span class="pln">responseXML</span><span class="pun">;</span><span class="pln">
 13.1764 +    </span><span class="pun">}</span><span class="pln">
 13.1765 +
 13.1766 +    </span><span class="com">// Service messaging to mute the provided service</span><span class="pln">
 13.1767 +    </span><span class="kwd">var</span><span class="pln"> svcMsg </span><span class="pun">=</span><span class="pln"> </span><span class="str">'&lt;?xml version="1.0" encoding="utf-8"?&gt;'</span><span class="pln"> </span><span class="pun">+</span><span class="pln">
 13.1768 +                 </span><span class="str">'&lt;s:Envelope s:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" '</span><span class="pln"> </span><span class="pun">+</span><span class="pln">
 13.1769 +                   </span><span class="str">'xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"&gt;'</span><span class="pln"> </span><span class="pun">+</span><span class="pln">
 13.1770 +                   </span><span class="str">'&lt;s:Body&gt;'</span><span class="pln"> </span><span class="pun">+</span><span class="pln">
 13.1771 +                     </span><span class="str">'&lt;u:SetMute xmlns:u="urn:schemas-upnp-org:service:RenderingControl:1"&gt;'</span><span class="pln"> </span><span class="pun">+</span><span class="pln">
 13.1772 +                       </span><span class="str">'&lt;InstanceID&gt;0&lt;/InstanceID&gt;'</span><span class="pln"> </span><span class="pun">+</span><span class="pln">
 13.1773 +                       </span><span class="str">'&lt;Channel&gt;Master&lt;/Channel&gt;'</span><span class="pln"> </span><span class="pun">+</span><span class="pln">
 13.1774 +                       </span><span class="str">'&lt;DesiredMute&gt;true&lt;/DesiredMute&gt;'</span><span class="pln"> </span><span class="pun">+</span><span class="pln">
 13.1775 +                     </span><span class="str">'&lt;/u:SetMute&gt;'</span><span class="pln"> </span><span class="pun">+</span><span class="pln">
 13.1776 +                   </span><span class="str">'&lt;/s:Body&gt;'</span><span class="pln"> </span><span class="pun">+</span><span class="pln">
 13.1777 +                 </span><span class="str">'&lt;/s:Envelope&gt;'</span><span class="pun">;</span><span class="pln">
 13.1778 +
 13.1779 +    svcXhr</span><span class="pun">.</span><span class="pln">send</span><span class="pun">(</span><span class="pln">svcMsg</span><span class="pun">);</span><span class="pln">
 13.1780 +    debug</span><span class="pun">.</span><span class="pln">innerHTML </span><span class="pun">+=</span><span class="pln"> </span><span class="str">"&lt;br&gt;"</span><span class="pln"> </span><span class="pun">+</span><span class="pln"> services</span><span class="pun">[</span><span class="lit">0</span><span class="pun">].</span><span class="pln">name </span><span class="pun">+</span><span class="pln"> </span><span class="str">" request sent: "</span><span class="pun">;</span><span class="pln">
 13.1781 +    debug</span><span class="pun">.</span><span class="pln">textContent </span><span class="pun">+=</span><span class="pln"> svcMsg</span><span class="pun">;</span><span class="pln">
 13.1782 +  </span><span class="pun">}</span><span class="pln">
 13.1783 +
 13.1784 +  </span><span class="kwd">function</span><span class="pln"> errorCallback</span><span class="pun">(</span><span class="pln"> error </span><span class="pun">)</span><span class="pln"> </span><span class="pun">{</span><span class="pln">
 13.1785 +    debug</span><span class="pun">.</span><span class="pln">innerHTML </span><span class="pun">+=</span><span class="pln"> </span><span class="str">"&lt;br&gt;An error occurred: "</span><span class="pln"> </span><span class="pun">+</span><span class="pln"> error</span><span class="pun">.</span><span class="pln">code</span><span class="pun">;</span><span class="pln">
 13.1786 +  </span><span class="pun">}</span><span class="pln">
 13.1787 +</span><span class="tag">&lt;/script&gt;</span></pre>
 13.1788 +          </div>
 13.1789 +
 13.1790 +       </section>
 13.1791 +
 13.1792 +    <section id="acknowledgements">
 13.1793 +      <!--OddPage--><h2><span class="secno">B. </span>Acknowledgements</h2>
 13.1794 +
 13.1795 +      <p>Thanks are expressed by the editor to the following individuals for their feedback on this specification to date (in alphabetical order):
 13.1796 +      <br><br>
 13.1797 +      Gar Bergstedt, Lars-Erik Bolstad, Cathy Chan, Hari G Kumar, Bob Lund, Giuseppe Pascale, Marcin Simonides, Clarke Stevens, Christian Söderström, Mark Vickers, ...</p>
 13.1798 +
 13.1799 +      <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):
 13.1800 +      <br><br>
 13.1801 +      CableLabs, Opera Software ASA, <abbr title="World Wide Web Consortium">W3C</abbr> Device APIs Working Group, <abbr title="World Wide Web Consortium">W3C</abbr> Web and TV Interest Group, ...</p>
 13.1802 +    </section>
 13.1803 +
 13.1804 +
 13.1805 +<section id="references" class="appendix"><!--OddPage--><h2><span class="secno">C. </span>References</h2><section id="normative-references"><h3><span class="secno">C.1 </span>Normative references</h3><dl class="bibliography"><dt id="bib-DNS-SD">[DNS-SD]</dt><dd>S. Cheshire; M. Krochmal. <a href="http://files.dns-sd.org/draft-cheshire-dnsext-dns-sd.txt"><cite>DNS-Based Service Discovery.</cite></a> 27 February 2011. IETF Draft. URL: <a href="http://files.dns-sd.org/draft-cheshire-dnsext-dns-sd.txt">http://files.dns-sd.org/draft-cheshire-dnsext-dns-sd.txt</a>
 13.1806 +</dd><dt id="bib-DOM4">[DOM4]</dt><dd>Anne van Kesteren; Aryeh Gregor; Ms2ger. <a href="http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html/"><cite>DOM4.</cite></a> URL: <a href="http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html/">http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html/</a>
 13.1807 +</dd><dt id="bib-HTML5">[HTML5]</dt><dd>Ian Hickson; David Hyatt. <a href="http://www.w3.org/TR/html5"><cite>HTML5.</cite></a> 29 March 2012. W3C Working Draft. (Work in progress.) URL: <a href="http://www.w3.org/TR/html5">http://www.w3.org/TR/html5</a>
 13.1808 +</dd><dt id="bib-MDNS">[MDNS]</dt><dd>S. Cheshire; M. Krochmal. <a href="http://files.multicastdns.org/draft-cheshire-dnsext-multicastdns.txt"><cite>Multicast DNS.</cite></a> 14 February 2011. IETF Draft. URL: <a href="http://files.multicastdns.org/draft-cheshire-dnsext-multicastdns.txt">http://files.multicastdns.org/draft-cheshire-dnsext-multicastdns.txt</a>
 13.1809 +</dd><dt id="bib-RFC2119">[RFC2119]</dt><dd>S. Bradner. <a href="http://www.ietf.org/rfc/rfc2119.txt"><cite>Key words for use in RFCs to Indicate Requirement Levels.</cite></a> March 1997. Internet RFC 2119.  URL: <a href="http://www.ietf.org/rfc/rfc2119.txt">http://www.ietf.org/rfc/rfc2119.txt</a>
 13.1810 +</dd><dt id="bib-UPNP-DEVICEARCH11">[UPNP-DEVICEARCH11]</dt><dd><a href="http://upnp.org/specs/arch/UPnP-arch-DeviceArchitecture-v1.1.pdf"><cite>UPnP Device Architecture 1.1</cite></a>. 15 October 2008. UPnP Forum. PDF document. URL: <a href="http://upnp.org/specs/arch/UPnP-arch-DeviceArchitecture-v1.1.pdf">http://upnp.org/specs/arch/UPnP-arch-DeviceArchitecture-v1.1.pdf</a>
 13.1811 +</dd><dt id="bib-WEBIDL">[WEBIDL]</dt><dd>Cameron McCormack. <a href="http://www.w3.org/TR/2011/WD-WebIDL-20110927/"><cite>Web IDL.</cite></a> 27 September 2011. W3C Working Draft. (Work in progress.) URL: <a href="http://www.w3.org/TR/2011/WD-WebIDL-20110927/">http://www.w3.org/TR/2011/WD-WebIDL-20110927/</a>
 13.1812 +</dd></dl></section><section id="informative-references"><h3><span class="secno">C.2 </span>Informative references</h3><p>No informative references.</p></section></section></body></html>
 13.1813 \ No newline at end of file
    14.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    14.2 +++ b/discovery-api/Overview.src.html	Mon Sep 03 15:35:05 2012 +0200
    14.3 @@ -0,0 +1,1556 @@
    14.4 +<!DOCTYPE html>
    14.5 +<html>
    14.6 +  <head>
    14.7 +    <title>Networked Service Discovery and Messaging</title>
    14.8 +    <meta http-equiv='Content-Type' content='text/html;charset=utf-8'/>
    14.9 +    <script type="text/javascript" class='remove'>
   14.10 +      var respecConfig = {
   14.11 +          specStatus:   "ED",
   14.12 +          //publishDate:  "2012-08-22",
   14.13 +          shortName:    "discovery-api",
   14.14 +          edDraftURI:   "http://w3c-test.org/dap/discovery-api/",
   14.15 +          previousMaturity: "WD",
   14.16 +          previousPublishDate: "2012-08-07",
   14.17 +          editors: [
   14.18 +            {
   14.19 +              name:       "Rich Tibbett",
   14.20 +              //url:        "http://richt.me/",
   14.21 +              company:    "Opera Software ASA",
   14.22 +              companyURL: "http://opera.com/"
   14.23 +            },
   14.24 +            {
   14.25 +              name:       "Clarke Stevens",
   14.26 +              //url:      "",
   14.27 +              company:    "CableLabs",
   14.28 +              companyURL: "http://cablelabs.com/"
   14.29 +            }
   14.30 +          ],
   14.31 +          noIDLIn:      true,
   14.32 +          wg:           "Device APIs and Policy Working Group",
   14.33 +          wgURI:        "http://www.w3.org/2009/dap/",
   14.34 +          wgPublicList: "public-device-apis",
   14.35 +          wgPatentURI:  "http://www.w3.org/2004/01/pp-impl/43696/status"
   14.36 +      };
   14.37 +    </script>
   14.38 +
   14.39 +    <script src='http://www.w3.org/Tools/respec/respec-w3c-common' type="text/javascript" class='remove' async></script>
   14.40 +    <style type="text/css">
   14.41 +      /* Custom CSS optimizations (Richard Tibbett) */
   14.42 +
   14.43 +      /* Add better spacing to sections */
   14.44 +      section, .section { margin-bottom: 2em; }
   14.45 +
   14.46 +      /* Reduce note & issue render size */
   14.47 +      .note, .issue { font-size:0.8em; }
   14.48 +
   14.49 +      /* Add addition spacing to <ol> and <ul> for rule definition */
   14.50 +      ol.rule li, ul.rule li { padding:0.6em; }
   14.51 +
   14.52 +      pre.widl { border: solid thin; background: #EEEEEE; color: black; padding: 0.5em 1em; position: relative; }
   14.53 +      pre.widl :link, pre.widl :visited { color: #000; background: transparent; }
   14.54 +      pre.widl:before { content: "IDL"; font: bold small sans-serif; padding: 0.5em; background: white; position: absolute; top: 0; margin: -1px 0 0 -4em; width: 1.5em; border: thin solid; border-radius: 0 0 0 0.5em }
   14.55 +
   14.56 +      div.example { border: solid thin red; background: #F7DFE5; color: black; padding: 0.5em 1em; position: relative; margin: 1em 0 1em 4.6em; width: auto; }
   14.57 +      div.example:before { content: "EXAMPLE"; font: bold small sans-serif; padding: 0.5em; background: red; color: white; position: absolute; top: 0; margin: -1px 0 0 -7.6em; width: 5em; border: thin solid red; border-radius: 0 0 0 0.5em }
   14.58 +
   14.59 +      dl.domintro { color: green; margin: 2em 0 2em 2em; padding: 0.5em 1em; border: none; background: #DDFFDD; }
   14.60 +      hr + dl.domintro, div.impl + dl.domintro { margin-top: 2.5em; margin-bottom: 1.5em; }
   14.61 +      dl.domintro dt, dl.domintro dt * { color: black; text-decoration: none; }
   14.62 +      dl.domintro dd { margin: 0.5em 0 1em 2em; padding: 0; }
   14.63 +      dl.domintro dd p { margin: 0.5em 0; }
   14.64 +      dl.domintro code {font-size: inherit; font-style: italic; }
   14.65 +      dl.domintro:before { display: table; margin: -1em -0.5em 0.5em auto; width: auto; content: 'This box is non-normative. Implementation requirements are given below this box.'; color: red; border: solid 2px; background: white; padding: 0 0.25em; }
   14.66 +    </style>
   14.67 +  </head>
   14.68 +
   14.69 +  <body>
   14.70 +    <section id='abstract'>
   14.71 +      <p>
   14.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
   14.73 +        advertised via common discovery protocols within a user's network.
   14.74 +      </p>
   14.75 +    </section>
   14.76 +
   14.77 +    <section id='sotd'>
   14.78 +      <p>
   14.79 +        This document represents the early consensus of the group on the scope and features of the proposed
   14.80 +        API.
   14.81 +      </p>
   14.82 +    </section>
   14.83 +
   14.84 +    <section class="informative">
   14.85 +      <h3>Introduction</h3>
   14.86 +
   14.87 +      <p>To enable Web pages to connect and communicate with Local-networked Services provided over HTTP, this specification introduces the
   14.88 +      <a href="#navigatornetworkservice"><code>NavigatorNetworkService</code></a> interface.</p>
   14.89 +
   14.90 +      <p>
   14.91 +         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,
   14.92 +         is expected before the web page is able to interact with any Local-networked Services.
   14.93 +      </p>
   14.94 +
   14.95 +      <p>
   14.96 +         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.
   14.97 +      </p>
   14.98 +
   14.99 +      <p>
  14.100 +         The user agent, having captured all advertised services on the network from the Service Discovery mechanisms included in this recommendation, attempts to match
  14.101 +      the requested service type to a discovered service according to the processing described herein.
  14.102 +      </p>
  14.103 +
  14.104 +      <p>
  14.105 +          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.
  14.106 +          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.
  14.107 +      </p>
  14.108 +
  14.109 +      <p>
  14.110 +         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
  14.111 +         authorized via the provided API.
  14.112 +         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
  14.113 +         connected Local-networked Service.
  14.114 +      </p>
  14.115 +
  14.116 +      <div class="example">
  14.117 +       <p>Example of requesting a DNS-SD advertised service:</p>
  14.118 +       <hr />
  14.119 +       <pre class="highlight">function showServices( services ) {
  14.120 +  // Show a list of all the services provided to the web page
  14.121 +  for(var i = 0, l = services.length; i < l; i++) console.log( services[i].name );
  14.122 +}
  14.123 +
  14.124 +navigator.getNetworkServices('zeroconf:_boxee-jsonrpc._tcp', showServices);</pre>
  14.125 +      </div>
  14.126 +
  14.127 +      <div class="example">
  14.128 +        <p>Example of requesting a UPnP advertised service, also handling error conditions:</p>
  14.129 +        <hr />
  14.130 +        <pre class="highlight">function showServices( services ) {
  14.131 +  // Show a list of all the services provided to the web page
  14.132 +  for(var i = 0, l = services.length; i < l; i++) console.log( services[i].name );
  14.133 +}
  14.134 +
  14.135 +function error( e ) {
  14.136 +  console.log( "Error occurred: " + e.code );
  14.137 +}
  14.138 +
  14.139 +navigator.getNetworkServices('upnp:urn:schemas-upnp-org:service:ContentDirectory:1', showServices, error);</pre>
  14.140 +      </div>
  14.141 +
  14.142 +      <div class="example">
  14.143 +        <p>Example of requesting either a DNS-SD or UPnP advertised service:</p>
  14.144 +        <hr />
  14.145 +        <pre class="highlight">function showServices( services ) {
  14.146 +  // Show a list of all the services provided to the web page (+ service type)
  14.147 +  for(var i = 0, l = services.length; i < l; i++)
  14.148 +     console.log( services[i].name + '(' + services[i].type + ')' );
  14.149 +}
  14.150 +
  14.151 +navigator.getNetworkServices([
  14.152 +  'zeroconf:_boxee-jsonrpc._tcp',
  14.153 +  'upnp:urn:schemas-upnp-org:service:ContentDirectory:1'
  14.154 +], showServices);</pre>
  14.155 +      </div>
  14.156 +
  14.157 +      <p>For more detailed examples see the <a href="#examples">Examples</a> section.
  14.158 +    </section>
  14.159 +
  14.160 +    <section
  14.161 +     id='conformance'>
  14.162 +
  14.163 +     <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
  14.164 +     meaning of the key word ("must", "should", "may", etc) used in introducing the algorithm.</p>
  14.165 +
  14.166 +     <p>
  14.167 +      Some conformance requirements are phrased as requirements on attributes, methods or objects. Such requirements are to be interpreted as requirements on user agents.
  14.168 +     </p>
  14.169 +
  14.170 +     <p>
  14.171 +      Conformance requirements phrased as algorithms or specific steps may be implemented in any manner, so long as the end result is equivalent. (In particular, the algorithms defined in
  14.172 +      this specification are intended to be easy to follow, and not intended to be performant.)
  14.173 +     </p>
  14.174 +
  14.175 +     <p>
  14.176 +      The only conformance class defined by this specification is a <dfn>user agent</dfn>.
  14.177 +     </p>
  14.178 +
  14.179 +     <p>
  14.180 +      User agents may 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
  14.181 +      around platform-specific limitations.
  14.182 +     </p>
  14.183 +
  14.184 +     <p>
  14.185 +      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 must act as if
  14.186 +      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
  14.187 +      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
  14.188 +      is insufficient.
  14.189 +     </p>
  14.190 +
  14.191 +      <section>
  14.192 +         <h3>Dependencies</h3>
  14.193 +
  14.194 +         This specification relies on several other underlying specifications.
  14.195 +
  14.196 +         <dl>
  14.197 +            <dt>HTML</dt>
  14.198 +            <dd>Many fundamental concepts from HTML are used by this specification. [[!HTML5]]</dd>
  14.199 +            <dt>WebIDL</dt>
  14.200 +            <dd>The IDL blocks in this specification use the semantics of the WebIDL specification. [[!WEBIDL]]</dd>
  14.201 +         </dl>
  14.202 +      </section>
  14.203 +    </section>
  14.204 +
  14.205 +    <section>
  14.206 +      <h3>Terminology</h3>
  14.207 +
  14.208 +      <p>
  14.209 +         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>".
  14.210 +      </p>
  14.211 +
  14.212 +      <p>
  14.213 +         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
  14.214 +         other <code>Node</code> objects as defined in the DOM Core specifications. [[!DOM4]]
  14.215 +      </p>
  14.216 +
  14.217 +      <p>
  14.218 +         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.
  14.219 +      </p>
  14.220 +
  14.221 +      <p>
  14.222 +        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.
  14.223 +      </p>
  14.224 +
  14.225 +      <p>
  14.226 +        A <a>valid service type</a> provided in the <code>type</code> attribute of the <code>getNetworkServices()</code> 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.
  14.227 +      </p>
  14.228 +    </section>
  14.229 +
  14.230 +    <section>
  14.231 +     <h2>Requesting networked services</h2>
  14.232 +
  14.233 +
  14.234 +<pre class="widl">[Supplemental, NoInterfaceObject]
  14.235 +interface <dfn id="navigatornetworkservice">NavigatorNetworkService</dfn> {
  14.236 +  // Obtain a Local-networked Service
  14.237 +  void <a href="#dom-navigator-getnetworkservices">getNetworkServices</a>( in any type,
  14.238 +                           in <a href="#navigatornetworkservicesuccesscallback">NavigatorNetworkServiceSuccessCallback</a> successCallback,
  14.239 +                           in optional <a href="#navigatornetworkserviceerrorcallback">NavigatorNetworkServiceErrorCallback</a> errorCallback );
  14.240 +};
  14.241 +<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>;
  14.242 +
  14.243 +[Callback=FunctionOnly, NoInterfaceObject]
  14.244 +interface <dfn id="navigatornetworkservicesuccesscallback">NavigatorNetworkServiceSuccessCallback</dfn> {
  14.245 +  void handleEvent( in <a href="#networkservices">NetworkServices</a> services );
  14.246 +};
  14.247 +
  14.248 +[NoInterfaceObject]
  14.249 +interface <dfn id="navigatornetworkserviceerror">NavigatorNetworkServiceError</dfn> {
  14.250 +  const unsigned short <a href="#dom-navigatornetworkserviceerror-permission_denied">PERMISSION_DENIED_ERR</a> = 1;
  14.251 +  const unsigned short <a href="#dom-navigatornetworkserviceerror-unknown_type_prefix">UNKNOWN_TYPE_PREFIX_ERR</a> = 2;
  14.252 +  readonly attribute unsigned short <a href="#dom-navigatornetworkserviceerror-code">code</a>;
  14.253 +};
  14.254 +
  14.255 +[Callback=FunctionOnly, NoInterfaceObject]
  14.256 +interface <dfn id="navigatornetworkserviceerrorcallback">NavigatorNetworkServiceErrorCallback</dfn> {
  14.257 +  void handleEvent( in <a href="#navigatornetworkserviceerror">NavigatorNetworkServiceError</a> error );
  14.258 +};
  14.259 +</pre>
  14.260 +
  14.261 +  <section>
  14.262 +   <h2>Methods</h2>
  14.263 +
  14.264 +      <dl class="domintro">
  14.265 +        <dt>
  14.266 +          <var title="">window</var>
  14.267 +           .
  14.268 +          <code title="dom-navigator">
  14.269 +            <a href="http://www.whatwg.org/specs/web-apps/current-work/complete/timers.html#navigator">navigator</a>
  14.270 +          </code>
  14.271 +           .
  14.272 +          <code title="dom-navigator-getNetworkServices">
  14.273 +            <a href="#dom-navigator-getnetworkservices">getNetworkServices</a>
  14.274 +          </code>
  14.275 +          (
  14.276 +          <var title="">type</var>
  14.277 +          ,
  14.278 +          <var title="">successCallback</var>
  14.279 +           [,
  14.280 +          <var title="">errorCallback</var>
  14.281 +           ] )
  14.282 +        </dt>
  14.283 +        <dd>
  14.284 +          <p>Prompts the user to select one or more discovered network services that have advertised support for the requested service type.</p>
  14.285 +          <p>
  14.286 +            The
  14.287 +            <var title="">type</var>
  14.288 +             argument contains one or more <a>valid service type</a> tokens that the web page would like to interact with.
  14.289 +          </p>
  14.290 +          <p>
  14.291 +            If the user accepts, the
  14.292 +            <var title="">successCallback</var>
  14.293 +             is
  14.294 +          invoked, with one or more
  14.295 +            <code>
  14.296 +              <a href="#networkservice"><code>NetworkService</code></a>
  14.297 +            </code>
  14.298 +             objects as
  14.299 +          its argument.
  14.300 +          </p>
  14.301 +          <p>
  14.302 +            If the user declines, the
  14.303 +            <var title="">errorCallback</var>
  14.304 +             (if
  14.305 +          any) is invoked.
  14.306 +          </p>
  14.307 +        </dd>
  14.308 +      </dl>
  14.309 +
  14.310 +       <div>
  14.311 +          <p>
  14.312 +            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> MUST run the following steps:
  14.313 +          </p>
  14.314 +
  14.315 +          <ol class="rule">
  14.316 +
  14.317 +            <li>
  14.318 +              Let <var>requested control types</var> be initially set to an empty array.
  14.319 +            </li>
  14.320 +
  14.321 +            <li>
  14.322 +               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.
  14.323 +            </li>
  14.324 +
  14.325 +            <li>
  14.326 +               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>.
  14.327 +            </li>
  14.328 +
  14.329 +            <li>
  14.330 +               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> MUST <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
  14.331 +                 <a href="#dom-navigatornetworkserviceerror-code"><code>code</code></a> attribute has the numeric value 2
  14.332 +                  (<a href="#dom-navigatornetworkserviceerror-unknown_type_prefix"><code>UNKNOWN_TYPE_PREFIX_ERR</code></a>) as its argument,
  14.333 +                   abort any remaining steps and return.
  14.334 +            </li>
  14.335 +
  14.336 +            <li>
  14.337 +               <em>Process</em>: Let <var>services found</var> be an empty array.
  14.338 +            </li>
  14.339 +
  14.340 +            <li>
  14.341 +               For each <var>available service</var> in the <a>list of available service records</a> run the following steps:
  14.342 +               <ol class="rule">
  14.343 +                  <li>
  14.344 +                    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.
  14.345 +                  </li>
  14.346 +                  <li>
  14.347 +                     Continue at the next <var>available service</var>.
  14.348 +                  </li>
  14.349 +                  <li>
  14.350 +                     <em>Attach</em>: If <var>matched service</var> is not empty then run the following steps:
  14.351 +
  14.352 +                     <ol class="rule">
  14.353 +                        <li>
  14.354 +                           Let <var>new service object</var> be a new <a href="#networkservice"><code>NetworkService</code></a> object, mapping the parameters of
  14.355 +                     <var>matched service</var> to this new object where possible.
  14.356 +                        </li>
  14.357 +                        <li>
  14.358 +                           Append <var>new service object</var> to the <var>services found</var> array.
  14.359 +                        </li>
  14.360 +                     </ol>
  14.361 +                  </li>
  14.362 +               </ol>
  14.363 +            </li>
  14.364 +
  14.365 +            <li>
  14.366 +               If <var>services found</var> is an empty array, then the <a>user agent</a> MUST <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
  14.367 +                 <a href="#dom-navigatornetworkserviceerror-code"><code>code</code></a> attribute has the numeric value 1
  14.368 +                 (<a href="#dom-navigatornetworkserviceerror-permission_denied"><code>PERMISSION_DENIED_ERR</code></a>) as its argument, abort any remaining steps and return.
  14.369 +            </li>
  14.370 +
  14.371 +            <li>
  14.372 +               Return, and run the remaining steps asynchronously.
  14.373 +            </li>
  14.374 +
  14.375 +            <li>
  14.376 +               Optionally, e.g. based on a previously-established user preference, for security reasons, or due to platform limitations, the <a>user agent</a> MAY <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
  14.377 +                 <a href="#dom-navigatornetworkserviceerror-code"><code>code</code></a> attribute has the numeric value 1
  14.378 +                 (<a href="#dom-navigatornetworkserviceerror-permission_denied"><code>PERMISSION_DENIED_ERR</code></a>) as its argument, abort any remaining steps and return.
  14.379 +            </li>
  14.380 +
  14.381 +            <li>
  14.382 +                  The <a>user agent</a> MUST prompt the user in a user-agent-specific manner for permission to provide the
  14.383 +                  <a href="http://www.whatwg.org/specs/web-apps/current-work/complete/browsers.html#entry-script" class="externalDFN">entry script</a>'s
  14.384 +                  <a href="http://www.whatwg.org/specs/web-apps/current-work/complete/origin-0.html#origin" class="externalDFN">origin</a> with an array of
  14.385 +                  <a href="#networkservice"><code>NetworkService</code></a> objects representing the user-authorized subset of <var>services found</var>.
  14.386 +
  14.387 +               <p>
  14.388 +                  If the user grants permission to access one or more networked services then the <a>user agent</a> SHOULD include an
  14.389 +                  "ongoing local-network communication" indicator.
  14.390 +               </p>
  14.391 +
  14.392 +               <p>If the user denies permission, then the <a>user agent</a> MUST <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
  14.393 +                <a href="#dom-navigatornetworkserviceerror-code"><code>code</code></a> attribute has the numeric value 1
  14.394 +                (<a href="#dom-navigatornetworkserviceerror-permission_denied"><code>PERMISSION_DENIED_ERR</code></a>) as its argument, abort any remaining steps and return.
  14.395 +              </p>
  14.396 +
  14.397 +              <p>
  14.398 +                If the user never responds, this algorithm stalls on this step.
  14.399 +              </p>
  14.400 +
  14.401 +            </li>
  14.402 +
  14.403 +            <li>
  14.404 +               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.
  14.405 +            </li>
  14.406 +
  14.407 +            <li>
  14.408 +               For each Object <var>service</var> in <var>services</var>, run the following substeps:
  14.409 +
  14.410 +               <ol class="rule">
  14.411 +                  <li>
  14.412 +                     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>.
  14.413 +                  </li>
  14.414 +                  <li>
  14.415 +                    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>.
  14.416 +                  </li>
  14.417 +               </ol>
  14.418 +            </li>
  14.419 +
  14.420 +            <li>
  14.421 +               Let <var>services manager</var> be a new <a href="#networkservices"><code>NetworkServices</code></a> object.
  14.422 +            </li>
  14.423 +
  14.424 +            <li>
  14.425 +               Set <var>services manager</var>'s <a href="#dom-networkservices-servicesavailable"><code>servicesAvailable</code></a> attribute to the length of <var>services</var>.
  14.426 +            </li>
  14.427 +
  14.428 +            <li>
  14.429 +              Store the set of <var>services</var> as <dfn id="current_authorized_services">current authorized services</dfn> internally against the newly created <var>services manager</var> object.
  14.430 +            </li>
  14.431 +
  14.432 +            <li>
  14.433 +               The <a>user agent</a> MUST <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
  14.434 +               <var>services manager</var> as its argument.
  14.435 +            </li>
  14.436 +
  14.437 +          </ol>
  14.438 +
  14.439 +          <p>
  14.440 +            The <a href="http://www.whatwg.org/specs/web-apps/current-work/complete/webappapis.html#task-source" class="externalDFN">task source</a> for these
  14.441 +            <a href="http://www.whatwg.org/specs/web-apps/current-work/complete/webappapis.html#concept-task" class="externalDFN">tasks</a> is the
  14.442 +            <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>.
  14.443 +          </p>
  14.444 +
  14.445 +          <p>
  14.446 +            When a <a href="#networkservice"><code>NetworkService</code></a> object is provided to a Web page, the <a>user agent</a> MUST add the <code>url</code> property
  14.447 +             to the <dfn>entry script origin's URL whitelist</dfn>. This list enables the
  14.448 +            Web page to override and initiate cross-site resource requests towards these URLs, and any sub-resources of these URLs, within the current
  14.449 +            <a href="http://www.whatwg.org/specs/web-apps/current-work/complete/browsers.html#entry-script" class="externalDFN">entry script</a>'s
  14.450 +            <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,
  14.451 +            Web Messaging, XMLHttpRequest).
  14.452 +         </p>
  14.453 +
  14.454 +         <p>
  14.455 +            If the user navigates away from the current browsing context, the <a>user agent</a> MUST remove all previously whitelisted urls from the <a>entry script origin's URL whitelist</a>.
  14.456 +            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:
  14.457 +            <ul>
  14.458 +              <li>If the current script is reloaded at any point in the same or different window.</li>
  14.459 +              <li>if the current script reinvokes the <a href="#dom-navigator-getnetworkservices"><code>getNetworkServices()</code></a> method at any point in its execution.</li>
  14.460 +              <li>If the user navigates forward or back in their history to reload the current page.</li>
  14.461 +              <li>If a script is running in a different origin.</li>
  14.462 +            </ul>
  14.463 +         </p>
  14.464 +
  14.465 +      </div>
  14.466 +      </section>
  14.467 +
  14.468 +      <section>
  14.469 +         <h3>Error Handling</h3>
  14.470 +
  14.471 +      <dl class="domintro">
  14.472 +        <dt>
  14.473 +          <var title="">error</var>
  14.474 +           .
  14.475 +          <code title="dom-NavigatorNetworkServiceError-code">
  14.476 +            <a href="#dom-navigatornetworkserviceerror-code">code</a>
  14.477 +          </code>
  14.478 +        </dt>
  14.479 +        <dd>
  14.480 +          <p>
  14.481 +            Returns the current error's error code. At the current time, this may be <code>1</code> or <code>2</code>, for which the
  14.482 +            corresponding error constants
  14.483 +            <a href="#dom-navigatornetworkserviceerror-permission_denied"><code>PERMISSION_DENIED_ERR</code></a> and
  14.484 +            <a href="#dom-navigatornetworkserviceerror-unknown_type_prefix"><code>UNKNOWN_TYPE_PREFIX_ERR</code></a> are defined.
  14.485 +          </p>
  14.486 +        </dd>
  14.487 +      </dl>
  14.488 +
  14.489 +         <p>
  14.490 +            The <dfn id="dom-navigatornetworkserviceerror-code" title="dom-navigatornetworkserviceerror-code"><code>code</code></dfn> attribute of a
  14.491 +            <a href="#navigatornetworkserviceerror"><code>NavigatorNetworkServiceError</code></a> object MUST return the code for the error, which will be one of the following:
  14.492 +         </p>
  14.493 +
  14.494 +         <dl>
  14.495 +            <dt>
  14.496 +               <dfn id="dom-navigatornetworkserviceerror-permission_denied" title="dom-navigatornetworkserviceerror-permission_denied"><code>PERMISSION_DENIED_ERR</code></dfn> (numeric value 1)
  14.497 +            </dt>
  14.498 +            <dd>
  14.499 +               The user or user agent denied the page permission to access any services.
  14.500 +            </dd>
  14.501 +            <dt>
  14.502 +               <dfn id="dom-navigatornetworkserviceerror-unknown_type_prefix" title="dom-navigatornetworkserviceerror-unknown_type_prefix"><code>UNKNOWN_TYPE_PREFIX_ERR</code></dfn> (numeric value 2)
  14.503 +            </dt>
  14.504 +            <dd>
  14.505 +               No <a>valid service type</a> tokens were provided in the method invocation.
  14.506 +            </dd>
  14.507 +         </dl>
  14.508 +
  14.509 +      </section>
  14.510 +
  14.511 +      </section>
  14.512 +      <section>
  14.513 +      <h2>Obtaining networked services</h2>
  14.514 +
  14.515 +      <p>
  14.516 +         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.
  14.517 +      </p>
  14.518 +
  14.519 +<pre class="widl">
  14.520 +[NoInterfaceObject]
  14.521 +interface <dfn id="networkservices">NetworkServices</dfn> {
  14.522 +  readonly attribute unsigned long    <a href="#dom-networkservices-length">length</a>;
  14.523 +  getter <a href="#networkservice">NetworkService</a> (unsigned long index);
  14.524 +  <a href="#networkservice">NetworkService</a>? <a href="#dom-networkservices-getservicebyid">getServiceById</a>(DOMString id);
  14.525 +
  14.526 +  readonly attribute unsigned long    <a href="#dom-networkservices-servicesavailable">servicesAvailable</a>;
  14.527 +
  14.528 +  // event handler attributes
  14.529 +           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>;
  14.530 +           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>;
  14.531 +
  14.532 +};
  14.533 +
  14.534 +<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>;
  14.535 +</pre>
  14.536 +
  14.537 +      <section>
  14.538 +      <h2>Attributes</h2>
  14.539 +
  14.540 +        <dl class="domintro">
  14.541 +          <dt>
  14.542 +            <code title="dom-networkservices-length">
  14.543 +              <a href="#dom-networkservices-length">length</a>
  14.544 +            </code>
  14.545 +          </dt>
  14.546 +          <dd>
  14.547 +            <p>
  14.548 +              Returns the current number of services in the respective object's <a>current authorized services</a>.
  14.549 +            </p>
  14.550 +          </dd>
  14.551 +          <dt>
  14.552 +            <code title="dom-networkservices-servicesavailable">
  14.553 +              <a href="#dom-networkservices-servicesavailable">servicesAvailable</a>
  14.554 +            </code>
  14.555 +          </dt>
  14.556 +          <dd>
  14.557 +            <p>
  14.558 +              Returns the current number of services matching one of the app-requested <a>valid service type</a> tokens that are actively available within the user's current network.
  14.559 +            </p>
  14.560 +          </dd>
  14.561 +        </dl>
  14.562 +
  14.563 +        <div>
  14.564 +           <p>
  14.565 +              The <dfn id="dom-networkservices-length"><code>length</code></dfn> attribute MUST return the number of services represented in the object's corresponding <a>current authorized services</a> list at the time of getting.
  14.566 +           </p>
  14.567 +
  14.568 +           <p>
  14.569 +              The <dfn id="dom-networkservices-servicesavailable"><code>servicesAvailable</code></dfn> attribute MUST return the number of services available in the
  14.570 +              user's network that match the <a>valid service type</a> that was initially used to create the current <a href="#networkservices"><code>NetworkServices</code></a> object.
  14.571 +           </p>
  14.572 +
  14.573 +           <p>
  14.574 +             When a previously unknown instance of a networked service matching one of the requested <a href="#dfn-valid-service-type">valid service types</a> becomes available on the user's current network, the <a>user agent</a> MUST increment the <a href="#dom-networkservices-servicesavailable"><code>servicesAvailable</code></a> attribute by <code>1</code> and then
  14.575 +             <a href="http://www.whatwg.org/specs/web-apps/current-work/complete/webappapis.html#queue-a-task" class="externalDFN">queue a task</a>
  14.576 +             to dispatch a newly created event with the name <code>serviceavailable</code> that uses the <code>Event</code> interface, which does
  14.577 +             not bubble, is not cancellable, and has no default action, at the current <a href="#networkservices"><code>NetworkServices</code></a>
  14.578 +             object.
  14.579 +           </p>
  14.580 +
  14.581 +           <p>
  14.582 +             When a previously known instance of a networked service matching one of the requested <a href="#dfn-valid-service-type">valid service types</a> becomes unavailable on the user's current network, the <a>user agent</a> MUST decrement the <a href="#dom-networkservices-servicesavailable"><code>servicesAvailable</code></a> attribute by <code>1</code> and then
  14.583 +             <a href="http://www.whatwg.org/specs/web-apps/current-work/complete/webappapis.html#queue-a-task" class="externalDFN">queue a task</a>
  14.584 +              to dispatch a newly created event with the name <code>serviceunavailable</code> that uses the <code>Event</code> interface, which does
  14.585 +              not bubble, is not cancellable, and has no default action, at the current <a href="#networkservices"><code>NetworkServices</code></a>
  14.586 +              object.
  14.587 +           </p>
  14.588 +        </div>
  14.589 +
  14.590 +      </section>
  14.591 +
  14.592 +      <section>
  14.593 +      <h2>Methods</h2>
  14.594 +        <dl class="domintro">
  14.595 +        <dt>
  14.596 +          <code title="networkservices-getter">
  14.597 +            <a href="#networkservices">services</a>
  14.598 +          </code>
  14.599 +          [
  14.600 +          <var title="">index</var>
  14.601 +          ]
  14.602 +        </dt>
  14.603 +        <dd>
  14.604 +          <p>
  14.605 +            Returns the specified <a href="#networkservice"><code>NetworkService</code></a> object.
  14.606 +          </p>
  14.607 +        </dd>
  14.608 +        <dt>
  14.609 +          <code title="networkservices-getter">
  14.610 +            <a href="#networkservices">services</a>
  14.611 +          </code>
  14.612 +          .
  14.613 +          <code title="dom-networkservices-getservicebyid">
  14.614 +            <a href="#dom-networkservices-getservicebyid">getServiceById</a>
  14.615 +          </code>
  14.616 +          (
  14.617 +          <var title="">id</var>
  14.618 +          )
  14.619 +        </dt>
  14.620 +        <dd>
  14.621 +          <p>
  14.622 +            Returns the <a href="#networkservice"><code>NetworkService</code></a> object with the given identifier, or null if no
  14.623 +            service has that identifier.
  14.624 +          </p>
  14.625 +        </dd>
  14.626 +      </dl>
  14.627 +
  14.628 +      <p>
  14.629 +        A <a href="#networkservices"><code>NetworkServices</code></a> object represents the current list of zero or more <a>current authorized services</a>, of which zero or more can be available at a time. Each item in <a>current authorized services</a> is represented by a <a href="#networkservice"><code>NetworkService</code></a> object. The list of <a>current authorized services</a> is <span>immutable</span> meaning that it cannot be modified for the lifetime of a <a href="#networkservices"><code>NetworkServices</code></a> object.
  14.630 +      </p>
  14.631 +
  14.632 +      <p class="note">
  14.633 +        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. If the <a>user agent</a> dynamically adds or removes network services for any reason, then the indices of the services in <a>current authorized services</a> will change dynamically. If the set of network services changes entirely, then all the previous services will be removed from <a>current authorized services</a> and replaced with new services.
  14.634 +      </p>
  14.635 +
  14.636 +      <p>
  14.637 +        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 <a>current authorized services</a> represented by the respective object minus one, if any services are represented in <a>current authorized services</a>. If a <a href="#networkservices"><code>NetworkServices</code></a> object represents no <a>current authorized services</a>, it has no <a href="http://www.whatwg.org/specs/web-apps/current-work/multipage/infrastructure.html#supported-property-indices" class="externalDFN">supported property indices</a>.
  14.638 +      </p>
  14.639 +
  14.640 +      <p>
  14.641 +        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>current authorized services</a>, the user agent MUST return the <a href="#networkservice"><code>NetworkService</code></a> object that represents the <var>index</var>th service in <a>current authorized services</a>.
  14.642 +      </p>
  14.643 +
  14.644 +      <p>
  14.645 +        The <dfn id="dom-networkservices-getservicebyid"><code>getServiceById(id)</code></dfn> method MUST return the first <a href="#networkservice"><code>NetworkService</code></a> object in <a>current authorized services</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.
  14.646 +        When no services in <a>current authorized services</a> match the given argument, the method MUST return null.
  14.647 +      </p>
  14.648 +
  14.649 +      <p>
  14.650 +         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
  14.651 +         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
  14.652 +         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.
  14.653 +      </p>
  14.654 +
  14.655 +      </section>
  14.656 +
  14.657 +      <section>
  14.658 +      <h2>Events</h2>
  14.659 +
  14.660 +      <p>
  14.661 +         The following are the event handlers (and their corresponding event handler event types) that must be supported, as IDL attributes, by all objects implementing the <a href="#networkservices"><code>NetworkServices</code></a> interface:
  14.662 +       </p>
  14.663 +
  14.664 +       <table border="1">
  14.665 +        <thead>
  14.666 +          <tr>
  14.667 +            <th>
  14.668 +              <span title="event handlers">Event handler</span>
  14.669 +            </th>
  14.670 +            <th>
  14.671 +              <span>Event handler event type</span>
  14.672 +            </th>
  14.673 +          </tr>
  14.674 +        </thead>
  14.675 +        <tbody>
  14.676 +          <tr>
  14.677 +            <td>
  14.678 +              <dfn id="dom-networkservices-onserviceavailable" title="dom-NetworkServices-onserviceavailable">
  14.679 +                <code>onserviceavailable</code>
  14.680 +              </dfn>
  14.681 +            </td>
  14.682 +            <td>
  14.683 +              <code title="event-serviceavailable">serviceavailable</code>
  14.684 +            </td>
  14.685 +          </tr>
  14.686 +          <tr>
  14.687 +            <td>
  14.688 +              <dfn id="dom-networkservices-onserviceunavailable" title="dom-NetworkServices-onserviceunavailable">
  14.689 +                <code>onserviceunavailable</code>
  14.690 +              </dfn>
  14.691 +            </td>
  14.692 +            <td>
  14.693 +              <code title="event-serviceunavailable">serviceunavailable</code>
  14.694 +            </td>
  14.695 +          </tr>
  14.696 +        </tbody>
  14.697 +      </table>
  14.698 +
  14.699 +      <p>
  14.700 +         Events with an event type of <code>serviceavailable</code> or <code>serviceunavailable</code> defined in this specification are simple <code>Event</code> objects.
  14.701 +      </p>
  14.702 +
  14.703 +      </section>
  14.704 +
  14.705 +    </section>
  14.706 +    <section>
  14.707 +    <h2>Communicating with a networked service</h3>
  14.708 +
  14.709 +<p>
  14.710 +   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.
  14.711 +</p>
  14.712 +
  14.713 +<pre class="widl">
  14.714 +[NoInterfaceObject]
  14.715 +interface <dfn id="networkservice">NetworkService</dfn> {
  14.716 +  readonly attribute DOMString        <a href="#dom-networkservice-id">id</a>;
  14.717 +  readonly attribute DOMString        <a href="#dom-networkservice-name">name</a>;
  14.718 +  readonly attribute DOMString        <a href="#dom-networkservice-type">type</a>;
  14.719 +  readonly attribute DOMString        <a href="#dom-networkservice-url">url</a>;
  14.720 +  readonly attribute DOMString        <a href="#dom-networkservice-config">config</a>;
  14.721 +
  14.722 +  readonly attribute boolean          <a href="#dom-networkservice-online">online</a>;
  14.723 +
  14.724 +  // event handler attributes
  14.725 +           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>;
  14.726 +           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>;
  14.727 +
  14.728 +           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>;
  14.729 +};
  14.730 +
  14.731 +<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>;
  14.732 +</pre>
  14.733 +
  14.734 +<section>
  14.735 +  <h2>Attributes</h2>
  14.736 +
  14.737 +      <dl class="domintro">
  14.738 +        <dt>
  14.739 +          <var title="">service</var>
  14.740 +           .
  14.741 +          <code title="dom-networkservice-id">
  14.742 +            <a href="#dom-networkservice-id">id</a>
  14.743 +          </code>
  14.744 +        </dt>
  14.745 +        <dd>
  14.746 +          <p>
  14.747 +            A unique identifier for the given user-selected service instance.
  14.748 +          </p>
  14.749 +        </dd>
  14.750 +        <dt>
  14.751 +          <var title="">service</var>
  14.752 +           .
  14.753 +          <code title="dom-networkservice-name">
  14.754 +            <a href="#dom-networkservice-name">name</a>
  14.755 +          </code>
  14.756 +        </dt>
  14.757 +        <dd>
  14.758 +          <p>
  14.759 +            The name of the user-selected service.
  14.760 +          </p>
  14.761 +        </dd>
  14.762 +        <dt>
  14.763 +          <var title="">service</var>
  14.764 +           .
  14.765 +          <code title="dom-networkservice-type">
  14.766 +            <a href="#dom-networkservice-type">type</a>
  14.767 +          </code>
  14.768 +        </dt>
  14.769 +        <dd>
  14.770 +          <p>
  14.771 +            The <a>valid service type</a> token value of the user-selected service.
  14.772 +          </p>
  14.773 +        </dd>
  14.774 +        <dt>
  14.775 +          <var title="">service</var>
  14.776 +           .
  14.777 +          <code title="dom-networkservice-url">
  14.778 +            <a href="#dom-networkservice-url">url</a>
  14.779 +          </code>
  14.780 +        </dt>
  14.781 +        <dd>
  14.782 +          <p>
  14.783 +            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>.
  14.784 +          </p>
  14.785 +        </dd>
  14.786 +        <dt>
  14.787 +          <var title="">service</var>
  14.788 +           .
  14.789 +          <code title="dom-networkservice-config">
  14.790 +            <a href="#dom-networkservice-config">config</a>
  14.791 +          </code>
  14.792 +        </dt>
  14.793 +        <dd>
  14.794 +          <p>
  14.795 +            The configuration information associated with the service depending on the requested service type.
  14.796 +          </p>
  14.797 +        </dd>
  14.798 +      </dl>
  14.799 +
  14.800 +          <p>
  14.801 +            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 MUST have the same <a href="#dom-networkservice-id"><code>id</code></a> value.
  14.802 +         </p>
  14.803 +
  14.804 +         <p>
  14.805 +            The <dfn id="dom-networkservice-name"><code>name</code></dfn> attribute represents a human-readable title for the service.
  14.806 +         </p>
  14.807 +
  14.808 +         <p>
  14.809 +             The <dfn id="dom-networkservice-type"><code>type</code></dfn> attribute reflects the value of the <a>valid service type</a> of the service.
  14.810 +          </p>
  14.811 +
  14.812 +         <p>
  14.813 +            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
  14.814 +            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).
  14.815 +         </p>
  14.816 +
  14.817 +         <p>
  14.818 +            The <dfn id="dom-networkservice-config"><code>config</code></dfn> attribute provides the raw configuration information extracted from the given network service.
  14.819 +         </p>
  14.820 +
  14.821 +      </section>
  14.822 +
  14.823 +      <section>
  14.824 +         <h3>States</h3>
  14.825 +
  14.826 +      <dl class="domintro">
  14.827 +        <dt>
  14.828 +          <var title="">service</var>
  14.829 +           .
  14.830 +          <code title="dom-networkservice-online">
  14.831 +            <a href="#dom-networkservice-online">online</a>
  14.832 +          </code>
  14.833 +        </dt>
  14.834 +        <dd>
  14.835 +          <p>
  14.836 +            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.
  14.837 +          </p>
  14.838 +        </dd>
  14.839 +      </dl>
  14.840 +
  14.841 +      <p>
  14.842 +        The <dfn id="dom-networkservice-online"><code>online</code></dfn> attribute indicates whether the service is reporting itself as being
  14.843 +        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 MUST default to <code>true</code>.
  14.844 +      </p>
  14.845 +
  14.846 +      </section>
  14.847 +
  14.848 +      <section>
  14.849 +         <h3>Events</h3>
  14.850 +
  14.851 +      <p>
  14.852 +         The following are the event handlers (and their corresponding event handler event types) that must be supported, as IDL attributes, by all objects implementing the
  14.853 +         <a href="#networkservice"><code>NetworkService</code></a> interface:
  14.854 +       </p>
  14.855 +
  14.856 +       <table border="1">
  14.857 +        <thead>
  14.858 +          <tr>
  14.859 +            <th>
  14.860 +              <span title="event handlers">Event handler</span>
  14.861 +            </th>
  14.862 +            <th>
  14.863 +              <span>Event handler event type</span>
  14.864 +            </th>
  14.865 +          </tr>
  14.866 +        </thead>
  14.867 +        <tbody>
  14.868 +          <tr>
  14.869 +            <td>
  14.870 +              <dfn id="dom-networkservice-onnotify" title="dom-NetworkService-onnotify">
  14.871 +                <code>onnotify</code>
  14.872 +              </dfn>
  14.873 +            </td>
  14.874 +            <td>
  14.875 +              <code title="event-notify">notify</code>
  14.876 +            </td>
  14.877 +          </tr>
  14.878 +          <tr>
  14.879 +            <td>
  14.880 +              <dfn id="dom-networkservice-onserviceonline" title="dom-NetworkService-onserviceonline">
  14.881 +                <code>onserviceonline</code>
  14.882 +              </dfn>
  14.883 +            </td>
  14.884 +            <td>
  14.885 +              <code title="event-onserviceonline">serviceonline</code>
  14.886 +            </td>
  14.887 +          </tr>
  14.888 +          <tr>
  14.889 +            <td>
  14.890 +              <dfn id="dom-networkservice-onserviceoffline" title="dom-NetworkService-onserviceoffline">
  14.891 +                <code>onserviceoffline</code>
  14.892 +              </dfn>
  14.893 +            </td>
  14.894 +            <td>
  14.895 +              <code title="event-onserviceoffline">serviceoffline</code>
  14.896 +            </td>
  14.897 +          </tr>
  14.898 +        </tbody>
  14.899 +      </table>
  14.900 +
  14.901 +      <p>
  14.902 +         Events with an event type of <code>notify</code>, <code>serviceonline</code> or <code>serviceoffline</code> defined in this specification are simple <code>Event</code> objects.
  14.903 +      </p>
  14.904 +
  14.905 +      </section>
  14.906 +   </section>
  14.907 +
  14.908 +      <section>
  14.909 +            <h2>Service Discovery</h2>
  14.910 +
  14.911 +      <p>
  14.912 +         A <a>user agent</a> conforming to this specification MAY implement <acronym title="Simple Service Discovery Protocol">SSDP</acronym> [[!UPNP-DEVICEARCH11]] and Zeroconf [[!DNS-SD]] + [[!MDNS]] service discovery mechanisms
  14.913 +         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 MUST conform to the corresponding algorithms provided in this section of the specification.
  14.914 +      </p>
  14.915 +      <p>
  14.916 +         This section presents how the results of these two service discovery
  14.917 +         mechanisms will be matched to requested service types and how their properties will be applied to any resulting <a href="#networkservice"><code>NetworkService</code></a> objects.
  14.918 +      </p>
  14.919 +
  14.920 +      <p>
  14.921 +         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
  14.922 +         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
  14.923 +         invocation of this API from a Web page).
  14.924 +      </p>
  14.925 +
  14.926 +      <p>
  14.927 +         The <dfn>list of available service records</dfn> is a single dynamic internal lookup table within user agents that is used to track the current services available in the network at any given time.
  14.928 +         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
  14.929 +         services changes. Each record contained within this table contains the attributes: <code>id</code>, <code>name</code>, <code>type</code>, <code>url</code> and <code>config</code>.
  14.930 +      </p>
  14.931 +
  14.932 +            <section>
  14.933 +         <h4>Zeroconf (<abbr title="Multicast DNS">mDNS</abbr> + <abbr title="Domain Name System">DNS</abbr>-<abbr title="Service Discovery">SD</abbr>)</h4>
  14.934 +
  14.935 +         <p>
  14.936 +            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
  14.937 +   domain [[!MDNS]], the <a>user agent</a> MUST run the following steps:
  14.938 +         </p>
  14.939 +
  14.940 +         <ol class="rule">
  14.941 +
  14.942 +            <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>
  14.943 +
  14.944 +            <li>For each Object <var>service mDNS response</var> in <var>service mDNS responses</var>, run the following steps:
  14.945 +               <ol>
  14.946 +
  14.947 +                  <li>
  14.948 +                     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>.
  14.949 +                  </li>
  14.950 +
  14.951 +                  <li>
  14.952 +                     Set <var>network service record</var>'s <code>id</code> property to the value of the full PTR Service Instance Name [[!MDNS]].
  14.953 +                  </li>
  14.954 +
  14.955 +                  <li>
  14.956 +                     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]].
  14.957 +                  </li>
  14.958 +
  14.959 +                  <li>
  14.960 +                     Set <var>network service record</var>'s <code>type</code> property to the concatenation of the string <code>zeroconf:</code> followed by the value of the PTR Service Instance Name's <var>Service</var> component [[!MDNS]].
  14.961 +                  </li>
  14.962 +
  14.963 +                  <li>
  14.964 +                     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]].
  14.965 +                  </li>
  14.966 +
  14.967 +                  <li>
  14.968 +                     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]].
  14.969 +                  </li>
  14.970 +
  14.971 +                  <li>
  14.972 +                     For each Object <var>existing service record</var> in the current <a>list of available service records</a>, run the following sub-steps:
  14.973 +                     <ol class="rule">
  14.974 +
  14.975 +                       <li>
  14.976 +                        If the <var>existing service record</var>'s <code>id</code> property matches the value of the <var>network service record</var>'s <code>id</code>, then set the
  14.977 +                        value of <var>existing service record</var> in the current <a>list of available service records</a>  to the value of the
  14.978 +                        <var>network service record</var> and skip the next step.
  14.979 +                       </li>
  14.980 +                     </ol>
  14.981 +                  </li>
  14.982 +
  14.983 +                  <li>
  14.984 +                     Add <var>network service record</var> to the <a>list of available service records</a>.
  14.985 +                  </li>
  14.986 +
  14.987 +                  <li>
  14.988 +                     For each non-garbage collected <a href="#networkservice"><code>NetworkService</code></a> object run the following steps:
  14.989 +
  14.990 +                     <ol class="rule">
  14.991 +                        <li>
  14.992 +                           If the <a href="#networkservice"><code>NetworkService</code></a> object's <code>type</code> attribute does not equal the
  14.993 +                           current <a>network service record</a>'s <code>type</code> property then continue at the next available active
  14.994 +                           <a href="#networkservice"><code>NetworkService</code></a> object.
  14.995 +                        </li>
  14.996 +                        <li>
  14.997 +                           Increment the <a href="#dom-networkservices-servicesavailable"><code>servicesAvailable</code></a> attribute of the <a href="#networkservices"><code>NetworkServices</code></a> object by <code>1</code>.
  14.998 +                        </li>
  14.999 +                        <li>
 14.1000 +                          <a href="http://www.whatwg.org/specs/web-apps/current-work/complete/webappapis.html#queue-a-task" class="externalDFN">Queue a task</a>
 14.1001 +                           to dispatch a newly created event with the name <code>serviceavailable</code> that uses the <code>Event</code> interface, which does not bubble, is not cancellable, and has no default action, at the current
 14.1002 +                            <a href="#networkservices"><code>NetworkServices</code></a> object.
 14.1003 +                        </li>
 14.1004 +                        <li>
 14.1005 +                          <a href="http://www.whatwg.org/specs/web-apps/current-work/complete/webappapis.html#queue-a-task" class="externalDFN">Queue a task</a>
 14.1006 +                           to dispatch a newly created event with the name <code>serviceonline</code> that uses the <code>Event</code> interface, which does not bubble, is not cancellable, and has no default action, at the current
 14.1007 +                           <a href="#networkservice"><code>NetworkService</code></a> object.
 14.1008 +                        </li>
 14.1009 +                     </ol>
 14.1010 +                  </li>
 14.1011 +            </ol>
 14.1012 +           </li>
 14.1013 +         </ol>
 14.1014 +
 14.1015 +      </section>
 14.1016 +
 14.1017 +      <section>
 14.1018 +         <h5>Universal Plug-and-Play (<abbr title="Universal Plug-and-Play">UPnP</abbr>)</h5>
 14.1019 +
 14.1020 +         <p>
 14.1021 +            For each SSDP Presence Announcement [[!UPNP-DEVICEARCH11]] - a HTTP NOTIFY request - received from a user-agent-initiated SSDP Discovery Request [[!UPNP-DEVICEARCH11]], the <a>user agent</a> MUST run the following steps:
 14.1022 +         </p>
 14.1023 +
 14.1024 +         <ol class="rule">
 14.1025 +            <li>
 14.1026 +               Let <var>ssdp device</var> be an Object with a property for each HTTP header received in the received SSDP Presence Announcement, with each key being the name of a HTTP header and its
 14.1027 +               value being that HTTP header's accompanying value.
 14.1028 +            </li>
 14.1029 +
 14.1030 +            <li>
 14.1031 +               If <var>ssdp device</var> does not contain at least one <var>NTS</var>, <var>USN</var> and <var>Location</var> parameter, then the <a>user agent</a> MUST abort these steps.
 14.1032 +            </li>
 14.1033 +
 14.1034 +            <li>
 14.1035 +               If the first occurrence of <var>NTS</var> has a value other than <code>ssdp:alive</code>, then continue to the step labeled <var>update service monitor</var> below.
 14.1036 +            </li>
 14.1037 +
 14.1038 +            <li>
 14.1039 +               Let <var>root device descriptor file</var> contain the contents of the file located at the URL provided in the first occurrence of <var>Location</var> obtained according to the rules
 14.1040 +               defined in the section 'Retrieving a description using HTTP' [[!UPNP-DEVICEARCH11]].
 14.1041 +            </li>
 14.1042 +
 14.1043 +            <li>
 14.1044 +               If <var>root device descriptor file</var> is empty, then the <a>user agent</a> MUST abort these steps.
 14.1045 +            </li>
 14.1046 +
 14.1047 +            <li>
 14.1048 +               Let <var>advertised services</var> be a <a>list of all advertised services</a> obtained from the <var>root device descriptor file</var> containing all sub-nodes of the <code>serviceList</code> node as described in
 14.1049 +               the section 'Device Description' [[!UPNP-DEVICEARCH11]].
 14.1050 +            </li>
 14.1051 +
 14.1052 +            <li>
 14.1053 +               For each Object <var>advertised service</var> in <var>advertised services</var> run the following steps:
 14.1054 +               <ol class="rule">
 14.1055 +
 14.1056 +                  <li>
 14.1057 +                     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>eventsUrl</code>, <code>config</code>.
 14.1058 +                  </li>
 14.1059 +
 14.1060 +                  <li>
 14.1061 +                     Set <var>network service record</var>'s <code>id</code> property to the string value of the first occurrence of <var>ssdp device</var>'s <var>USN</var> parameter.
 14.1062 +                  </li>
 14.1063 +
 14.1064 +                  <li>
 14.1065 +                     Set <var>network service record</var>'s <code>name</code> property to the string value of the first occurrence of the <var>service</var>'s <code>serviceId</code> property.
 14.1066 +                  </li>
 14.1067 +
 14.1068 +                  <li>
 14.1069 +                     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>service</var>'s <code>serviceType</code> property.
 14.1070 +                  </li>
 14.1071 +
 14.1072 +                  <li>
 14.1073 +                     Set <var>network service record</var>'s <code>url</code> property to the string value of the first occurrence of the <var>service</var>'s <code>controlURL</code> property.
 14.1074 +                  </li>
 14.1075 +
 14.1076 +                  <li>
 14.1077 +                     Set <var>network service record</var>'s <code>config</code> property to the string value of the first occurrence of the <var>device</var> property.
 14.1078 +                  </li>
 14.1079 +
 14.1080 +                  <li>
 14.1081 +                     If <var>service</var>'s <code>eventSubURL</code> property is empty, then continue to the step labeled <em>register</em> below.
 14.1082 +                  </li>
 14.1083 +
 14.1084 +                  <li>
 14.1085 +                     Set <var>network service record</var>'s <code>eventsUrl</code> property to the string value of the first occurrence of the <var>service</var>'s <code>eventSubURL</code> property.
 14.1086 +                  </li>
 14.1087 +
 14.1088 +                  <li>
 14.1089 +                     <em>Register</em>: For each Object <var>existing service record</var> in the current <a>list of available service records</a>, run the following sub-steps:
 14.1090 +                     <ol class="rule">
 14.1091 +
 14.1092 +                       <li>
 14.1093 +                        If the <var>existing service record</var>'s <var>id</var> property matches the value of the first occurrence of <var>USN</var> and the
 14.1094 +                        <var>existing service record</var>'s <code>type</code> property matches the value of <var>network service record</var>'s <code>type</code>, then set the
 14.1095 +                        value of <var>existing service record</var> in the current <a>list of available service records</a>  to the value of the
 14.1096 +                        <var>network service record</var> and skip the next step.
 14.1097 +                       </li>
 14.1098 +                     </ol>