Bug 1343442 - decode-error/warning tests - r?gijs draft
authorGerald Squelart <gsquelart@mozilla.com>
Tue, 11 Apr 2017 09:35:17 +1200
changeset 560840 a4dded63672b7c3a1b4887831f9d4080d8d6b1fc
parent 560839 a74e566ff286a51725d84af89cfadb41ef4be9b7
child 623812 2a61416b29f3afdb56b971d6475767b2f3ae2145
push id53551
push usergsquelart@mozilla.com
push dateTue, 11 Apr 2017 23:47:44 +0000
reviewersgijs
bugs1343442
milestone55.0a1
Bug 1343442 - decode-error/warning tests - r?gijs MozReview-Commit-ID: A0HO6RrnpMC
browser/base/content/test/general/browser_decoderDoctor.js
--- 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"}));
+});