From 5f8de423f190bbb79a62f804151bc24824fa32d8 Mon Sep 17 00:00:00 2001 From: "Matt A. Tobin" Date: Fri, 2 Feb 2018 04:16:08 -0500 Subject: Add m-esr52 at 52.6.0 --- toolkit/components/alerts/test/.eslintrc.js | 7 + toolkit/components/alerts/test/image.gif | Bin 0 -> 60901 bytes toolkit/components/alerts/test/image.png | Bin 0 -> 2531 bytes toolkit/components/alerts/test/image_server.sjs | 82 ++++++++++ toolkit/components/alerts/test/mochitest.ini | 16 ++ toolkit/components/alerts/test/test_alerts.html | 89 +++++++++++ .../alerts/test/test_alerts_noobserve.html | 96 ++++++++++++ .../test/test_alerts_requireinteraction.html | 168 +++++++++++++++++++++ toolkit/components/alerts/test/test_image.html | 118 +++++++++++++++ .../alerts/test/test_multiple_alerts.html | 103 +++++++++++++ toolkit/components/alerts/test/test_principal.html | 122 +++++++++++++++ 11 files changed, 801 insertions(+) create mode 100644 toolkit/components/alerts/test/.eslintrc.js create mode 100644 toolkit/components/alerts/test/image.gif create mode 100644 toolkit/components/alerts/test/image.png create mode 100644 toolkit/components/alerts/test/image_server.sjs create mode 100644 toolkit/components/alerts/test/mochitest.ini create mode 100644 toolkit/components/alerts/test/test_alerts.html create mode 100644 toolkit/components/alerts/test/test_alerts_noobserve.html create mode 100644 toolkit/components/alerts/test/test_alerts_requireinteraction.html create mode 100644 toolkit/components/alerts/test/test_image.html create mode 100644 toolkit/components/alerts/test/test_multiple_alerts.html create mode 100644 toolkit/components/alerts/test/test_principal.html (limited to 'toolkit/components/alerts/test') diff --git a/toolkit/components/alerts/test/.eslintrc.js b/toolkit/components/alerts/test/.eslintrc.js new file mode 100644 index 000000000..3c788d6d6 --- /dev/null +++ b/toolkit/components/alerts/test/.eslintrc.js @@ -0,0 +1,7 @@ +"use strict"; + +module.exports = { + "extends": [ + "../../../../testing/mochitest/mochitest.eslintrc.js" + ] +}; diff --git a/toolkit/components/alerts/test/image.gif b/toolkit/components/alerts/test/image.gif new file mode 100644 index 000000000..053b4d926 Binary files /dev/null and b/toolkit/components/alerts/test/image.gif differ diff --git a/toolkit/components/alerts/test/image.png b/toolkit/components/alerts/test/image.png new file mode 100644 index 000000000..430c3c5e6 Binary files /dev/null and b/toolkit/components/alerts/test/image.png differ diff --git a/toolkit/components/alerts/test/image_server.sjs b/toolkit/components/alerts/test/image_server.sjs new file mode 100644 index 000000000..622052943 --- /dev/null +++ b/toolkit/components/alerts/test/image_server.sjs @@ -0,0 +1,82 @@ +const { classes: Cc, interfaces: Ci, utils: Cu, results: Cr, Constructor: CC } = Components; + +Cu.import("resource://gre/modules/Timer.jsm"); + +const LocalFile = CC("@mozilla.org/file/local;1", "nsILocalFile", + "initWithPath"); + +const FileInputStream = CC("@mozilla.org/network/file-input-stream;1", + "nsIFileInputStream", "init"); + +const BinaryInputStream = CC("@mozilla.org/binaryinputstream;1", + "nsIBinaryInputStream", "setInputStream"); + +function handleRequest(request, response) { + let params = parseQueryString(request.queryString); + + response.setStatusLine(request.httpVersion, 200, "OK"); + + // Compare and increment a cookie for this request. This is used to test + // private browsing mode; the cookie should not be set if the image is + // loaded anonymously. + if (params.has("c")) { + let expectedValue = parseInt(params.get("c"), 10); + let actualValue = !request.hasHeader("Cookie") ? 0 : + parseInt(request.getHeader("Cookie") + .replace(/^counter=(\d+)/, "$1"), 10); + if (actualValue != expectedValue) { + response.setStatusLine(request.httpVersion, 400, "Wrong counter value"); + return; + } + response.setHeader("Set-Cookie", `counter=${expectedValue + 1}`, false); + } + + // Wait to send the image if a timeout is given. + let timeout = parseInt(params.get("t"), 10); + if (timeout > 0) { + response.processAsync(); + setTimeout(() => { + respond(params, request, response); + response.finish(); + }, timeout * 1000); + return; + } + + respond(params, request, response); +} + +function parseQueryString(queryString) { + return queryString.split("&").reduce((params, param) => { + let [key, value] = param.split("=", 2); + params.set(key, value); + return params; + }, new Map()); +} + +function respond(params, request, response) { + if (params.has("s")) { + let statusCode = parseInt(params.get("s"), 10); + response.setStatusLine(request.httpVersion, statusCode, "Custom status"); + return; + } + var filename = params.get("f"); + writeFile(filename, response); +} + +function writeFile(name, response) { + var file = new LocalFile(getState("__LOCATION__")).parent; + file.append(name); + + let mimeType = Cc["@mozilla.org/uriloader/external-helper-app-service;1"] + .getService(Ci.nsIMIMEService) + .getTypeFromFile(file); + + let fileStream = new FileInputStream(file, 1, 0, false); + let binaryStream = new BinaryInputStream(fileStream); + + response.setHeader("Content-Type", mimeType, false); + response.bodyOutputStream.writeFrom(binaryStream, binaryStream.available()); + + binaryStream.close(); + fileStream.close(); +} diff --git a/toolkit/components/alerts/test/mochitest.ini b/toolkit/components/alerts/test/mochitest.ini new file mode 100644 index 000000000..12e2a8704 --- /dev/null +++ b/toolkit/components/alerts/test/mochitest.ini @@ -0,0 +1,16 @@ +[DEFAULT] +support-files = + image.gif + image.png + image_server.sjs + +# Synchronous tests like test_alerts.html must come before +# asynchronous tests like test_alerts_noobserve.html! +[test_alerts.html] +skip-if = toolkit == 'android' +[test_alerts_noobserve.html] +[test_alerts_requireinteraction.html] +[test_image.html] +[test_multiple_alerts.html] +[test_principal.html] +skip-if = toolkit == 'android' diff --git a/toolkit/components/alerts/test/test_alerts.html b/toolkit/components/alerts/test/test_alerts.html new file mode 100644 index 000000000..cb087e48a --- /dev/null +++ b/toolkit/components/alerts/test/test_alerts.html @@ -0,0 +1,89 @@ + + + + + Test for Alerts Service + + + + + +

+ +
Alerts service, with observer "synchronous" case. +
+
Did a notification appear anywhere? +
If so, the test will finish once the notification disappears. + +
+
+
+ + diff --git a/toolkit/components/alerts/test/test_alerts_noobserve.html b/toolkit/components/alerts/test/test_alerts_noobserve.html new file mode 100644 index 000000000..0cc452b8a --- /dev/null +++ b/toolkit/components/alerts/test/test_alerts_noobserve.html @@ -0,0 +1,96 @@ + + + + + Test for Alerts Service + + + + + +

+ +
Alerts service, without observer "asynchronous" case. +
+
A notification should soon appear somewhere. +
If there has been no crash when the notification (later) disappears, assume all is good. + +
+
+
+ + diff --git a/toolkit/components/alerts/test/test_alerts_requireinteraction.html b/toolkit/components/alerts/test/test_alerts_requireinteraction.html new file mode 100644 index 000000000..26fe87104 --- /dev/null +++ b/toolkit/components/alerts/test/test_alerts_requireinteraction.html @@ -0,0 +1,168 @@ + + + + Test for alerts with requireInteraction + + + + + +
+
+
+ + diff --git a/toolkit/components/alerts/test/test_image.html b/toolkit/components/alerts/test/test_image.html new file mode 100644 index 000000000..7bf89fab2 --- /dev/null +++ b/toolkit/components/alerts/test/test_image.html @@ -0,0 +1,118 @@ + + + + Test for Bug 1233086 + + + + + + +

+ +
+
+
+ + diff --git a/toolkit/components/alerts/test/test_multiple_alerts.html b/toolkit/components/alerts/test/test_multiple_alerts.html new file mode 100644 index 000000000..9d939b63a --- /dev/null +++ b/toolkit/components/alerts/test/test_multiple_alerts.html @@ -0,0 +1,103 @@ + + + + Test for multiple alerts + + + + + +
+
+
+ + diff --git a/toolkit/components/alerts/test/test_principal.html b/toolkit/components/alerts/test/test_principal.html new file mode 100644 index 000000000..74a20dbd7 --- /dev/null +++ b/toolkit/components/alerts/test/test_principal.html @@ -0,0 +1,122 @@ + + + + Test for Bug 1202933 + + + + + + +

+ +
+
+
+ + -- cgit v1.2.3