mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 03:15:11 +00:00
Bug 1242965 - Make services/common eslintable. r=rnewman
This commit is contained in:
parent
37eab7e51a
commit
0067cc1e04
@ -2,14 +2,10 @@
|
|||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
* 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/. */
|
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
#ifndef MERGED_COMPARTMENT
|
|
||||||
|
|
||||||
this.EXPORTED_SYMBOLS = ["Async"];
|
this.EXPORTED_SYMBOLS = ["Async"];
|
||||||
|
|
||||||
var {classes: Cc, interfaces: Ci, results: Cr, utils: Cu} = Components;
|
var {classes: Cc, interfaces: Ci, results: Cr, utils: Cu} = Components;
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Constants for makeSyncCallback, waitForSyncCallback.
|
// Constants for makeSyncCallback, waitForSyncCallback.
|
||||||
const CB_READY = {};
|
const CB_READY = {};
|
||||||
const CB_COMPLETE = {};
|
const CB_COMPLETE = {};
|
||||||
|
@ -14,8 +14,11 @@ EXTRA_COMPONENTS += [
|
|||||||
]
|
]
|
||||||
|
|
||||||
EXTRA_JS_MODULES['services-common'] += [
|
EXTRA_JS_MODULES['services-common'] += [
|
||||||
|
'async.js',
|
||||||
'logmanager.js',
|
'logmanager.js',
|
||||||
'moz-kinto-client.js',
|
'moz-kinto-client.js',
|
||||||
|
'observers.js',
|
||||||
|
'rest.js',
|
||||||
'stringbundle.js',
|
'stringbundle.js',
|
||||||
'utils.js',
|
'utils.js',
|
||||||
]
|
]
|
||||||
@ -31,12 +34,6 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] != 'android' or CONFIG['MOZ_B2GDROID']:
|
|||||||
'modules-testing/storageserver.js',
|
'modules-testing/storageserver.js',
|
||||||
]
|
]
|
||||||
|
|
||||||
EXTRA_PP_JS_MODULES['services-common'] += [
|
|
||||||
'async.js',
|
|
||||||
'observers.js',
|
|
||||||
'rest.js',
|
|
||||||
]
|
|
||||||
|
|
||||||
TESTING_JS_MODULES.services.common += [
|
TESTING_JS_MODULES.services.common += [
|
||||||
'modules-testing/logging.js',
|
'modules-testing/logging.js',
|
||||||
'modules-testing/utils.js',
|
'modules-testing/utils.js',
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* 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/. */
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
#ifndef MERGED_COMPARTMENT
|
|
||||||
|
|
||||||
this.EXPORTED_SYMBOLS = ["Observers"];
|
this.EXPORTED_SYMBOLS = ["Observers"];
|
||||||
|
|
||||||
var Cc = Components.classes;
|
var Cc = Components.classes;
|
||||||
@ -11,8 +9,6 @@ var Ci = Components.interfaces;
|
|||||||
var Cr = Components.results;
|
var Cr = Components.results;
|
||||||
var Cu = Components.utils;
|
var Cu = Components.utils;
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
* 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/. */
|
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
#ifndef MERGED_COMPARTMENT
|
|
||||||
|
|
||||||
var {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
|
var {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
|
||||||
|
|
||||||
this.EXPORTED_SYMBOLS = [
|
this.EXPORTED_SYMBOLS = [
|
||||||
@ -12,8 +10,6 @@ this.EXPORTED_SYMBOLS = [
|
|||||||
"TokenAuthenticatedRESTRequest",
|
"TokenAuthenticatedRESTRequest",
|
||||||
];
|
];
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
Cu.import("resource://gre/modules/Preferences.jsm");
|
Cu.import("resource://gre/modules/Preferences.jsm");
|
||||||
Cu.import("resource://gre/modules/Services.jsm");
|
Cu.import("resource://gre/modules/Services.jsm");
|
||||||
Cu.import("resource://gre/modules/NetUtil.jsm");
|
Cu.import("resource://gre/modules/NetUtil.jsm");
|
||||||
|
@ -44,7 +44,7 @@ add_task(function test_updateClockOffset() {
|
|||||||
do_check_true(Math.abs(client.localtimeOffsetMsec + HOUR_MS) <= SECOND_MS);
|
do_check_true(Math.abs(client.localtimeOffsetMsec + HOUR_MS) <= SECOND_MS);
|
||||||
});
|
});
|
||||||
|
|
||||||
add_task(function test_authenticated_get_request() {
|
add_task(function* test_authenticated_get_request() {
|
||||||
let message = "{\"msg\": \"Great Success!\"}";
|
let message = "{\"msg\": \"Great Success!\"}";
|
||||||
let method = "GET";
|
let method = "GET";
|
||||||
|
|
||||||
@ -66,7 +66,7 @@ add_task(function test_authenticated_get_request() {
|
|||||||
yield deferredStop(server);
|
yield deferredStop(server);
|
||||||
});
|
});
|
||||||
|
|
||||||
function check_authenticated_request(method) {
|
function* check_authenticated_request(method) {
|
||||||
let server = httpd_setup({"/foo": (request, response) => {
|
let server = httpd_setup({"/foo": (request, response) => {
|
||||||
do_check_true(request.hasHeader("Authorization"));
|
do_check_true(request.hasHeader("Authorization"));
|
||||||
|
|
||||||
@ -98,7 +98,7 @@ add_task(function test_authenticated_patch_request() {
|
|||||||
check_authenticated_request("PATCH");
|
check_authenticated_request("PATCH");
|
||||||
});
|
});
|
||||||
|
|
||||||
add_task(function test_credentials_optional() {
|
add_task(function* test_credentials_optional() {
|
||||||
let method = "GET";
|
let method = "GET";
|
||||||
let server = httpd_setup({
|
let server = httpd_setup({
|
||||||
"/foo": (request, response) => {
|
"/foo": (request, response) => {
|
||||||
@ -118,7 +118,7 @@ add_task(function test_credentials_optional() {
|
|||||||
yield deferredStop(server);
|
yield deferredStop(server);
|
||||||
});
|
});
|
||||||
|
|
||||||
add_task(function test_server_error() {
|
add_task(function* test_server_error() {
|
||||||
let message = "Ohai!";
|
let message = "Ohai!";
|
||||||
let method = "GET";
|
let method = "GET";
|
||||||
|
|
||||||
@ -141,7 +141,7 @@ add_task(function test_server_error() {
|
|||||||
yield deferredStop(server);
|
yield deferredStop(server);
|
||||||
});
|
});
|
||||||
|
|
||||||
add_task(function test_server_error_json() {
|
add_task(function* test_server_error_json() {
|
||||||
let message = JSON.stringify({error: "Cannot get ye flask."});
|
let message = JSON.stringify({error: "Cannot get ye flask."});
|
||||||
let method = "GET";
|
let method = "GET";
|
||||||
|
|
||||||
@ -163,7 +163,7 @@ add_task(function test_server_error_json() {
|
|||||||
yield deferredStop(server);
|
yield deferredStop(server);
|
||||||
});
|
});
|
||||||
|
|
||||||
add_task(function test_offset_after_request() {
|
add_task(function* test_offset_after_request() {
|
||||||
let message = "Ohai!";
|
let message = "Ohai!";
|
||||||
let method = "GET";
|
let method = "GET";
|
||||||
|
|
||||||
@ -186,7 +186,7 @@ add_task(function test_offset_after_request() {
|
|||||||
yield deferredStop(server);
|
yield deferredStop(server);
|
||||||
});
|
});
|
||||||
|
|
||||||
add_task(function test_offset_in_hawk_header() {
|
add_task(function* test_offset_in_hawk_header() {
|
||||||
let message = "Ohai!";
|
let message = "Ohai!";
|
||||||
let method = "GET";
|
let method = "GET";
|
||||||
|
|
||||||
@ -233,7 +233,7 @@ add_task(function test_offset_in_hawk_header() {
|
|||||||
yield deferredStop(server);
|
yield deferredStop(server);
|
||||||
});
|
});
|
||||||
|
|
||||||
add_task(function test_2xx_success() {
|
add_task(function* test_2xx_success() {
|
||||||
// Just to ensure that we're not biased toward 200 OK for success
|
// Just to ensure that we're not biased toward 200 OK for success
|
||||||
let credentials = {
|
let credentials = {
|
||||||
id: "eyJleHBpcmVzIjogMTM2NTAxMDg5OC4x",
|
id: "eyJleHBpcmVzIjogMTM2NTAxMDg5OC4x",
|
||||||
@ -257,7 +257,7 @@ add_task(function test_2xx_success() {
|
|||||||
yield deferredStop(server);
|
yield deferredStop(server);
|
||||||
});
|
});
|
||||||
|
|
||||||
add_task(function test_retry_request_on_fail() {
|
add_task(function* test_retry_request_on_fail() {
|
||||||
let attempts = 0;
|
let attempts = 0;
|
||||||
let credentials = {
|
let credentials = {
|
||||||
id: "eyJleHBpcmVzIjogMTM2NTAxMDg5OC4x",
|
id: "eyJleHBpcmVzIjogMTM2NTAxMDg5OC4x",
|
||||||
@ -312,7 +312,7 @@ add_task(function test_retry_request_on_fail() {
|
|||||||
yield deferredStop(server);
|
yield deferredStop(server);
|
||||||
});
|
});
|
||||||
|
|
||||||
add_task(function test_multiple_401_retry_once() {
|
add_task(function* test_multiple_401_retry_once() {
|
||||||
// Like test_retry_request_on_fail, but always return a 401
|
// Like test_retry_request_on_fail, but always return a 401
|
||||||
// and ensure that the client only retries once.
|
// and ensure that the client only retries once.
|
||||||
let attempts = 0;
|
let attempts = 0;
|
||||||
@ -361,7 +361,7 @@ add_task(function test_multiple_401_retry_once() {
|
|||||||
yield deferredStop(server);
|
yield deferredStop(server);
|
||||||
});
|
});
|
||||||
|
|
||||||
add_task(function test_500_no_retry() {
|
add_task(function* test_500_no_retry() {
|
||||||
// If we get a 500 error, the client should not retry (as it would with a
|
// If we get a 500 error, the client should not retry (as it would with a
|
||||||
// 401)
|
// 401)
|
||||||
let credentials = {
|
let credentials = {
|
||||||
@ -401,7 +401,7 @@ add_task(function test_500_no_retry() {
|
|||||||
yield deferredStop(server);
|
yield deferredStop(server);
|
||||||
});
|
});
|
||||||
|
|
||||||
add_task(function test_401_then_500() {
|
add_task(function* test_401_then_500() {
|
||||||
// Like test_multiple_401_retry_once, but return a 500 to the
|
// Like test_multiple_401_retry_once, but return a 500 to the
|
||||||
// second request, ensuring that the promise is properly rejected
|
// second request, ensuring that the promise is properly rejected
|
||||||
// in client.request.
|
// in client.request.
|
||||||
@ -465,7 +465,7 @@ add_task(function test_401_then_500() {
|
|||||||
yield deferredStop(server);
|
yield deferredStop(server);
|
||||||
});
|
});
|
||||||
|
|
||||||
add_task(function throw_if_not_json_body() {
|
add_task(function* throw_if_not_json_body() {
|
||||||
let client = new HawkClient("https://example.com");
|
let client = new HawkClient("https://example.com");
|
||||||
try {
|
try {
|
||||||
yield client.request("/bogus", "GET", {}, "I am not json");
|
yield client.request("/bogus", "GET", {}, "I am not json");
|
||||||
|
Loading…
Reference in New Issue
Block a user