Bug 1035369 Update the parameter name for the push url when registering with the Loop server to match with the latest version of the API. r=mdeboer
authorMark Banner <standard8@mozilla.com>
Tue, 29 Jul 2014 17:17:40 +0100
changeset 196639 af885bfee5f3fbab720dd5c969f5531d55edfe5b
parent 196638 ac8248c5b891626c7089f2d5fa9d95314cd38526
child 196640 7eb18ddea680db3c6b5cd681cab0562cc82a3a74
push id27220
push userkwierso@gmail.com
push dateWed, 30 Jul 2014 00:01:50 +0000
treeherdermozilla-central@f61a27b00e05 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmdeboer
bugs1035369
milestone34.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 1035369 Update the parameter name for the push url when registering with the Loop server to match with the latest version of the API. r=mdeboer
browser/components/loop/MozLoopService.jsm
browser/components/loop/test/xpcshell/head.js
browser/components/loop/test/xpcshell/test_loopservice_registration.js
--- a/browser/components/loop/MozLoopService.jsm
+++ b/browser/components/loop/MozLoopService.jsm
@@ -236,17 +236,17 @@ let MozLoopServiceInternal = {
 
   /**
    * Registers with the Loop server.
    *
    * @param {String} pushUrl The push url given by the push server.
    * @param {Boolean} noRetry Optional, don't retry if authentication fails.
    */
   registerWithLoopServer: function(pushUrl, noRetry) {
-    this.hawkRequest("/registration", "POST", { simple_push_url: pushUrl})
+    this.hawkRequest("/registration", "POST", { simplePushURL: pushUrl})
       .then((response) => {
         // If this failed we got an invalid token. storeSessionToken rejects
         // the gRegisteredDeferred promise for us, so here we just need to
         // early return.
         if (!this.storeSessionToken(response.headers))
           return;
 
         gRegisteredDeferred.resolve();
--- a/browser/components/loop/test/xpcshell/head.js
+++ b/browser/components/loop/test/xpcshell/head.js
@@ -42,22 +42,23 @@ function setupFakeLoopServer() {
  * This is used to fake push registration and notifications for
  * MozLoopService tests. There is only one object created per test instance, as
  * once registration has taken place, the object cannot currently be changed.
  */
 let mockPushHandler = {
   // This sets the registration result to be returned when initialize
   // is called. By default, it is equivalent to success.
   registrationResult: null,
+  registrationPushURL: undefined,
 
   /**
    * MozLoopPushHandler API
    */
   initialize: function(registerCallback, notificationCallback) {
-    registerCallback(this.registrationResult);
+    registerCallback(this.registrationResult, this.registrationPushURL);
     this._notificationCallback = notificationCallback;
   },
 
   /**
    * Test-only API to simplify notifying a push notification result.
    */
   notify: function(version) {
     this._notificationCallback(version);
--- a/browser/components/loop/test/xpcshell/test_loopservice_registration.js
+++ b/browser/components/loop/test/xpcshell/test_loopservice_registration.js
@@ -1,11 +1,13 @@
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
+Cu.import("resource://services-common/utils.js");
+
 /**
  * This file is to test general registration. Note that once successful
  * registration has taken place, we can no longer test the server side
  * parts as the service protects against this, hence, they need testing in
  * other test files.
  */
 
 /**
@@ -44,17 +46,24 @@ add_test(function test_register_websocke
   });
 });
 
 /**
  * Tests that we get a success response when both websocket and Loop server
  * registration are complete.
  */
 add_test(function test_register_success() {
+  mockPushHandler.registrationPushURL = kEndPointUrl;
+
   loopServer.registerPathHandler("/registration", (request, response) => {
+    let body = CommonUtils.readBytesFromInputStream(request.bodyInputStream);
+    let data = JSON.parse(body);
+    Assert.equal(data.simplePushURL, kEndPointUrl,
+                 "Should send correct push url");
+
     response.setStatusLine(null, 200, "OK");
     response.processAsync();
     response.finish();
   });
   MozLoopService.register(mockPushHandler).then(() => {
     run_next_test();
   }, err => {
     do_throw("shouldn't error on a successful request");