dap commit: update the test suite to match the spec <http://lists.w3.org/Archives/Public/public-device-apis/2013Feb/0036.html>

changeset:   395:eb6f23519b41
tag:         tip
user:        Anssi Kostiainen <anssi.kostiainen@nokia.com>
date:        Fri Feb 22 16:31:00 2013 +0200
files:       battery/tests/submissions/anssik/battery-interface-idlharness.html battery/tests/submissions/anssik/battery-interface.js
description:
update the test suite to match the spec <http://lists.w3.org/Archives/Public/public-device-apis/2013Feb/0036.html>


diff -r 80120ce78810 -r eb6f23519b41 battery/tests/submissions/anssik/battery-interface-idlharness.html
--- a/battery/tests/submissions/anssik/battery-interface-idlharness.html	Thu Feb 21 19:20:58 2013 +0200
+++ b/battery/tests/submissions/anssik/battery-interface-idlharness.html	Fri Feb 22 16:31:00 2013 +0200
@@ -6,27 +6,29 @@
     <script src="/resources/testharnessreport.js"></script>
     <script src="/resources/WebIDLParser.js"></script>
     <script src="/resources/idlharness.js"></script>
+    <script type="text/plain">
+    partial interface Navigator {
+        readonly attribute BatteryManager battery;
+    };
+    
+    interface BatteryManager : EventTarget {
+        readonly attribute boolean             charging;
+        readonly attribute unrestricted double chargingTime;
+        readonly attribute unrestricted double dischargingTime;
+        readonly attribute double              level;
+                 attribute EventHandler        onchargingchange;
+                 attribute EventHandler        onchargingtimechange;
+                 attribute EventHandler        ondischargingtimechange;
+                 attribute EventHandler        onlevelchange;
+    };
+    </script>
     <script>
     var idl_array = new IdlArray();
-    idl_array.add_untested_idls("interface Navigator { };");
-    idl_array.add_idls("Navigator implements NavigatorBattery;");
-    idl_array.add_idls("[NoInterfaceObject] interface NavigatorBattery {\
-        readonly attribute BatteryManager battery;\
-    };");
-    idl_array.add_idls("[NoInterfaceObject] interface BatteryManager : EventTarget {\
-        readonly attribute boolean   charging;\
-        readonly attribute double    chargingTime;\
-        readonly attribute double    dischargingTime;\
-        readonly attribute double    level;\
-        [TreatNonCallableAsNull]\
-                 attribute Function? onchargingchange;\
-        [TreatNonCallableAsNull]\
-                 attribute Function? onchargingtimechange;\
-        [TreatNonCallableAsNull]\
-                 attribute Function? ondischargingtimechange;\
-        [TreatNonCallableAsNull]\
-                 attribute Function? onlevelchange;\
-    };");
+    idl_array.add_untested_idls('interface Navigator { };');
+    var idls = document.querySelector('script[type=text\\/plain]').textContent;
+    // replace 'EventHandler' and 'unrestricted double' unrecognized by idlharness.js
+    idls = idls.replace('EventHandler', 'Function?', 'g').replace('unrestricted double', 'double', 'g');
+    idl_array.add_idls(idls);
     idl_array.add_objects({Navigator: ["navigator"], BatteryManager: ["navigator.battery"]});
     idl_array.test();
     </script>
@@ -38,7 +40,7 @@
     </p>
     <p>
       This test uses <a href="/resources/idlharness.js">idlharness.js</a>, and
-      is an alternative to the <a href="battery-interface.html">battery-interface.html</a>
+      is complementary to the <a href="battery-interface.html">battery-interface.html</a>
       test.
     </p>
     <div id="log"></div>
diff -r 80120ce78810 -r eb6f23519b41 battery/tests/submissions/anssik/battery-interface.js
--- a/battery/tests/submissions/anssik/battery-interface.js	Thu Feb 21 19:20:58 2013 +0200
+++ b/battery/tests/submissions/anssik/battery-interface.js	Fri Feb 22 16:31:00 2013 +0200
@@ -31,11 +31,8 @@
   
   /**
   *
-  * Navigator implements NavigatorBattery;
-  *
-  * [NoInterfaceObject]
-  * interface NavigatorBattery {
-  *    readonly attribute BatteryManager battery;
+  * partial interface Navigator {
+  *     readonly attribute BatteryManager battery;
   * };
   *
   */
@@ -45,12 +42,11 @@
   }, 'battery is present on navigator');
     
   test(function() {
-    assert_readonly(navigator, 'battery', 'battery must be readonly')
+    assert_readonly(navigator, 'battery', 'battery must be readonly');
   }, 'battery is readonly');
   
   /**
   *
-  * [NoInterfaceObject]
   * interface BatteryManager : EventTarget {
   *     readonly attribute boolean             charging;
   *     readonly attribute unrestricted double chargingTime;
@@ -65,6 +61,10 @@
   */
 
   // interface BatteryManager : EventTarget {
+
+  test(function() {
+      assert_own_property(window, 'BatteryManager');
+  }, 'window has an own property BatteryManager');
   
   test(function() {
       assert_true(navigator.battery instanceof EventTarget);

Received on Friday, 22 February 2013 14:31:18 UTC