Bug 1343442 - decode-error/warning tests - r?gijs
MozReview-Commit-ID: A0HO6RrnpMC
--- a/browser/base/content/test/general/browser_decoderDoctor.js
+++ b/browser/base/content/test/general/browser_decoderDoctor.js
@@ -79,16 +79,34 @@ function tab_checker_for_sumo(expectedPa
return function(openedTab) {
let baseURL = Services.urlFormatter.formatURLPref("app.support.baseURL");
let url = baseURL + expectedPath;
is(openedTab.linkedBrowser.currentURI.spec, url,
`Expected '${url}' in new tab`);
};
}
+function tab_checker_for_webcompat(expectedParams) {
+ return function(openedTab) {
+ let urlString = openedTab.linkedBrowser.currentURI.spec;
+ let endpoint = Services.prefs.getStringPref("media.decoder-doctor.new-issue-endpoint", "");
+ ok(urlString.startsWith(endpoint),
+ `Expected URL starting with '${endpoint}', got '${urlString}'`)
+ let params = new URL(urlString).searchParams;
+ for (let k in expectedParams) {
+ if (!params.has(k)) {
+ ok(false, `Expected ${k} in webcompat URL`);
+ } else {
+ is(params.get(k), expectedParams[k],
+ `Expected ${k}='${expectedParams[k]}' in webcompat URL`);
+ }
+ }
+ };
+}
+
add_task(function* test_platform_decoder_not_found() {
let message = "";
let isLinux = AppConstants.platform == "linux";
if (isLinux) {
message = gNavigatorBundle.getString("decoder.noCodecsLinux.message");
} else if (AppConstants.platform == "win") {
message = gNavigatorBundle.getString("decoder.noHWAcceleration.message");
}
@@ -122,8 +140,40 @@ add_task(function* test_unsupported_liba
if (AppConstants.platform == "linux") {
message =
gNavigatorBundle.getString("decoder.unsupportedLibavcodec.message");
}
yield test_decoder_doctor_notification(
{type: "unsupported-libavcodec", formats: "testFormat"}, message);
});
+
+add_task(function* test_decode_error() {
+ yield SpecialPowers.pushPrefEnv(
+ { set: [["media.decoder-doctor.new-issue-endpoint",
+ "http://127.0.0.1/webcompat"]] });
+ let message = gNavigatorBundle.getString("decoder.decodeError.message");
+ yield test_decoder_doctor_notification(
+ {type: "decode-error", decodeIssue: "DecodeIssue",
+ docURL: "DocURL", resourceURL: "ResURL"},
+ message,
+ gNavigatorBundle.getString("decoder.decodeError.button"),
+ gNavigatorBundle.getString("decoder.decodeError.accesskey"),
+ tab_checker_for_webcompat(
+ {url: "DocURL", problem_type: "video_bug",
+ details: "Technical Information:\nDecodeIssue\nResource: ResURL"}));
+});
+
+add_task(function* test_decode_warning() {
+ yield SpecialPowers.pushPrefEnv(
+ { set: [["media.decoder-doctor.new-issue-endpoint",
+ "http://127.0.0.1/webcompat"]] });
+ let message = gNavigatorBundle.getString("decoder.decodeWarning.message");
+ yield test_decoder_doctor_notification(
+ {type: "decode-warning", decodeIssue: "DecodeIssue",
+ docURL: "DocURL", resourceURL: "ResURL"},
+ message,
+ gNavigatorBundle.getString("decoder.decodeError.button"),
+ gNavigatorBundle.getString("decoder.decodeError.accesskey"),
+ tab_checker_for_webcompat(
+ {url: "DocURL", problem_type: "video_bug",
+ details: "Technical Information:\nDecodeIssue\nResource: ResURL"}));
+});