dap commit: add prime computation to the battery-unplugged test

changeset:   265:b0ba6739390f
tag:         tip
user:        Anssi Kostiainen <anssi.kostiainen@nokia.com>
date:        Wed Oct 31 11:56:27 2012 +0100
files:       battery/tests/submissions/anssik/battery-unplugged.html
description:
add prime computation to the battery-unplugged test


diff -r cda35cc7cd40 -r b0ba6739390f battery/tests/submissions/anssik/battery-unplugged.html
--- a/battery/tests/submissions/anssik/battery-unplugged.html	Wed Oct 31 11:43:48 2012 +0100
+++ b/battery/tests/submissions/anssik/battery-unplugged.html	Wed Oct 31 11:56:27 2012 +0100
@@ -49,9 +49,18 @@
       
       var onlevelchange_test = async_test('When the battery\'s level changes, must fire a levelchange event.');
       var battery_level = navigator.battery.level;
+      
+      // compute primes to deplete the battery faster
+      var w = new Worker('prime.js');
+      w.postMessage('compute');
+      w.onmessage = function (e) {
+        document.querySelector('#prime').textContent = e.data;
+      };
+      
       navigator.battery.onlevelchange = onlevelchange_test.step_func(function (e) {
         assert_true(navigator.battery.level > 0 && navigator.battery.level < 1.0, 'The level attribute must be set to the current battery level scaled from 0 to 1.0.');
         onlevelchange_test.done();
+        w.terminate();
       });
 
       alert('Unplug in the charger, and click OK.');

Received on Wednesday, 31 October 2012 10:53:43 UTC