зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1326225 - Fix un-imported fetch use in NormandyApi.jsm r=Gijs
See https://developer.mozilla.org/en-US/docs/Mozilla/Projects/Mochitest#How_do_I_test_issues_which_only_show_up_when_tests_are_run_across_domains.3F for info on how the test server was set up for testing that fetch was used correctly. r=Gijs MozReview-Commit-ID: CNH6SQ6gEGU --HG-- extra : rebase_source : a492de75e4189f10371427a4f6c342a672ea57cd
This commit is contained in:
Родитель
cd181bc396
Коммит
9974c78865
|
@ -10,6 +10,7 @@ Cu.import("resource://gre/modules/Services.jsm");
|
||||||
Cu.import("resource://gre/modules/Task.jsm");
|
Cu.import("resource://gre/modules/Task.jsm");
|
||||||
Cu.import("resource://gre/modules/CanonicalJSON.jsm");
|
Cu.import("resource://gre/modules/CanonicalJSON.jsm");
|
||||||
Cu.import("resource://gre/modules/Log.jsm");
|
Cu.import("resource://gre/modules/Log.jsm");
|
||||||
|
Cu.importGlobalProperties(["fetch"]); /* globals fetch */
|
||||||
|
|
||||||
this.EXPORTED_SYMBOLS = ["NormandyApi"];
|
this.EXPORTED_SYMBOLS = ["NormandyApi"];
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@ module.exports = {
|
||||||
is: false,
|
is: false,
|
||||||
isnot: false,
|
isnot: false,
|
||||||
ok: false,
|
ok: false,
|
||||||
|
SpecialPowers: false,
|
||||||
},
|
},
|
||||||
rules: {
|
rules: {
|
||||||
"spaced-comment": 2,
|
"spaced-comment": 2,
|
||||||
|
|
|
@ -4,3 +4,6 @@
|
||||||
[browser_Storage.js]
|
[browser_Storage.js]
|
||||||
[browser_Heartbeat.js]
|
[browser_Heartbeat.js]
|
||||||
skip-if = true # bug 1325409
|
skip-if = true # bug 1325409
|
||||||
|
[browser_NormandyApi.js]
|
||||||
|
support-files =
|
||||||
|
test_server.sjs
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
const {utils: Cu} = Components;
|
||||||
|
Cu.import("resource://shield-recipe-client/lib/NormandyApi.jsm", this);
|
||||||
|
|
||||||
|
add_task(function* () {
|
||||||
|
// Point the add-on to the test server.
|
||||||
|
yield SpecialPowers.pushPrefEnv({
|
||||||
|
set: [
|
||||||
|
[
|
||||||
|
"extensions.shield-recipe-client.api_url",
|
||||||
|
"http://mochi.test:8888/browser/browser/extensions/shield-recipe-client/test",
|
||||||
|
]
|
||||||
|
]
|
||||||
|
})
|
||||||
|
|
||||||
|
// Test that NormandyApi can fetch from the test server.
|
||||||
|
const response = yield NormandyApi.get("test_server.sjs");
|
||||||
|
const data = yield response.json();
|
||||||
|
Assert.deepEqual(data, {test: "data"}, "NormandyApi returned incorrect server data.");
|
||||||
|
});
|
|
@ -0,0 +1,8 @@
|
||||||
|
function handleRequest(request, response) {
|
||||||
|
// Allow cross-origin, so you can XHR to it!
|
||||||
|
response.setHeader("Access-Control-Allow-Origin", "*", false);
|
||||||
|
// Avoid confusing cache behaviors
|
||||||
|
response.setHeader("Cache-Control", "no-cache", false);
|
||||||
|
response.setHeader("Content-Type", "application/json", false);
|
||||||
|
response.write(JSON.stringify({test: "data"}))
|
||||||
|
}
|
|
@ -306,8 +306,8 @@ user_pref("browser.search.countryCode", "US");
|
||||||
user_pref("browser.search.geoSpecificDefaults", false);
|
user_pref("browser.search.geoSpecificDefaults", false);
|
||||||
|
|
||||||
// Make sure self support doesn't hit the network.
|
// Make sure self support doesn't hit the network.
|
||||||
user_pref("browser.selfsupport.url", "https://%(server)s/selfsupport-dummy/");
|
user_pref("browser.selfsupport.url", "https://example.com/selfsupport-dummy/");
|
||||||
user_pref("extensions.shield-recipe-client.api_url", "https://%(server)s/selfsupport-dummy/");
|
user_pref("extensions.shield-recipe-client.api_url", "https://example.com/selfsupport-dummy/");
|
||||||
|
|
||||||
user_pref("media.eme.enabled", true);
|
user_pref("media.eme.enabled", true);
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче