Bug 1128986 - Update gaia_lock_screen.js. r=jgriffin
authorAlexandre Lissy <lissyx@lissyx.dyndns.org>
Tue, 03 Feb 2015 10:49:00 -0500
changeset 256779 4dc28102814051775c29bb19b83f374e71406386
parent 256778 1219ad286c50cc8a7435453f0381df2ea72b6c43
child 256780 1da0551c005b9405862755f96518c8a0e52dab2a
push id4610
push userjlund@mozilla.com
push dateMon, 30 Mar 2015 18:32:55 +0000
treeherdermozilla-beta@4df54044d9ef [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjgriffin
bugs1128986
milestone38.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1128986 - Update gaia_lock_screen.js. r=jgriffin
layout/tools/reftest/gaia_lock_screen.js
--- a/layout/tools/reftest/gaia_lock_screen.js
+++ b/layout/tools/reftest/gaia_lock_screen.js
@@ -1,90 +1,60 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 // NOTE: This code was forked from:
 // https://github.com/mozilla-b2g/gaia/blob/master/tests/atoms/gaia_lock_screen.js
 
 'use strict';
+/* globals waitFor, finish */
+/* exported GaiaLockScreen */
 
 var GaiaLockScreen = {
 
-  unlock: function() {
-    let lockscreen = window.wrappedJSObject.lockScreen;
+  unlock: function(forcibly) {
     let setlock = window.wrappedJSObject.SettingsListener.getSettingsLock();
-    let system = window.wrappedJSObject.System;
+    let service = window.wrappedJSObject.Service;
     let obj = {'screen.timeout': 0};
     setlock.set(obj);
 
-    window.wrappedJSObject.ScreenManager.turnScreenOn();
-
     waitFor(
       function() {
-        window.wrappedJSObject.dispatchEvent(
-          new window.wrappedJSObject.CustomEvent(
-            'lockscreen-request-unlock', {
-              detail: {
-                forcibly: true
-              }
-            }));
+        service.request('unlock', { forcibly: forcibly });
         waitFor(
           function() {
-            finish(system.locked);
+            finish(service.locked);
           },
           function() {
-            return !system.locked;
+            return !service.locked;
           }
         );
       },
       function() {
-        return !!lockscreen;
+        return !!service;
       }
     );
   },
 
-  lock: function() {
-    let lwm = window.wrappedJSObject.lockScreenWindowManager;
-    let lockscreen = window.wrappedJSObject.lockScreen;
-    let system = window.wrappedJSObject.System;
+  lock: function(forcibly) {
+    let service = window.wrappedJSObject.Service;
     let setlock = window.wrappedJSObject.SettingsListener.getSettingsLock();
     let obj = {'screen.timeout': 0};
-    let waitLock = function() {
-      waitFor(
-        function() {
-        window.wrappedJSObject.dispatchEvent(
-          new window.wrappedJSObject.CustomEvent(
-            'lockscreen-request-lock', {
-              detail: {
-                forcibly: true
-              }
-            }));
-          waitFor(
-            function() {
-              finish(!system.locked);
-            },
-            function() {
-              return system.locked;
-            }
-          );
-        },
-        function() {
-          return !!lockscreen;
-        }
-      );
-    };
-
     setlock.set(obj);
-    window.wrappedJSObject.ScreenManager.turnScreenOn();
-
-    // Need to open the window before we lock the lockscreen.
-    // This would only happen when someone directly call the lockscrene.lock.
-    // It's a bad pattern and would only for test.
-    lwm.openApp();
-    waitFor(function() {
-      waitLock();
-    }, function() {
-      return lwm.states.instance.isActive();
-    });
+    waitFor(
+      function() {
+      service.request('lock', { forcibly: forcibly });
+        waitFor(
+          function() {
+            finish(!service.locked);
+          },
+          function() {
+            return service.locked;
+          }
+        );
+      },
+      function() {
+        return !!service;
+      }
+    );
   }
 };
-