summaryrefslogtreecommitdiff
path: root/toolkit/components/thumbnails/test/test_thumbnails_interfaces.js
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /toolkit/components/thumbnails/test/test_thumbnails_interfaces.js
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloaduxp-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
Add m-esr52 at 52.6.0
Diffstat (limited to 'toolkit/components/thumbnails/test/test_thumbnails_interfaces.js')
-rw-r--r--toolkit/components/thumbnails/test/test_thumbnails_interfaces.js31
1 files changed, 31 insertions, 0 deletions
diff --git a/toolkit/components/thumbnails/test/test_thumbnails_interfaces.js b/toolkit/components/thumbnails/test/test_thumbnails_interfaces.js
new file mode 100644
index 0000000000..8272b2e069
--- /dev/null
+++ b/toolkit/components/thumbnails/test/test_thumbnails_interfaces.js
@@ -0,0 +1,31 @@
+// tests to check that moz-page-thumb URLs correctly resolve as file:// URLS
+"use strict";
+
+const Cu = Components.utils;
+const Cc = Components.classes;
+const Cr = Components.results;
+const Ci = Components.interfaces;
+
+Cu.import("resource://gre/modules/Services.jsm");
+
+// need profile so that PageThumbsStorage can resolve the path to the underlying file
+do_get_profile();
+
+function run_test() {
+ // first check the protocol handler implements the correct interface
+ let handler = Services.io.getProtocolHandler("moz-page-thumb");
+ ok(handler instanceof Ci.nsISubstitutingProtocolHandler,
+ "moz-page-thumb handler provides substituting interface");
+
+ // then check that the file URL resolution works
+ let uri = Services.io.newURI("moz-page-thumb://thumbnail/?url=http%3A%2F%2Fwww.mozilla.org%2F",
+ null, null);
+ ok(uri instanceof Ci.nsIFileURL, "moz-page-thumb:// is a FileURL");
+ ok(uri.file, "This moz-page-thumb:// object is backed by a file");
+
+ // and check that the error case works as specified
+ let bad = Services.io.newURI("moz-page-thumb://wronghost/?url=http%3A%2F%2Fwww.mozilla.org%2F",
+ null, null);
+ Assert.throws(() => handler.resolveURI(bad), /NS_ERROR_NOT_AVAILABLE/i,
+ "moz-page-thumb object with wrong host must not resolve to a file path");
+}