summaryrefslogtreecommitdiffstats
path: root/dom/tests/mochitest/general/frameStorageNullprincipal.sjs
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 /dom/tests/mochitest/general/frameStorageNullprincipal.sjs
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'dom/tests/mochitest/general/frameStorageNullprincipal.sjs')
-rw-r--r--dom/tests/mochitest/general/frameStorageNullprincipal.sjs33
1 files changed, 33 insertions, 0 deletions
diff --git a/dom/tests/mochitest/general/frameStorageNullprincipal.sjs b/dom/tests/mochitest/general/frameStorageNullprincipal.sjs
new file mode 100644
index 000000000..4f58a296f
--- /dev/null
+++ b/dom/tests/mochitest/general/frameStorageNullprincipal.sjs
@@ -0,0 +1,33 @@
+// This is a sjs file which reads in frameStoragePrevented.html, and writes it out as a data: URI, which this page redirects to.
+// This produces a URI with the null principal, which should be unable to access storage.
+// We append the #nullprincipal hash to the end of the data: URI to tell the script that it shouldn't try to spawn a webworker,
+// as it won't be allowed to, as it has a null principal.
+
+function handleRequest(request, response) {
+ // Get the nsIFile for frameStoragePrevented.html
+ var file;
+ getObjectState("SERVER_ROOT", function(serverRoot) {
+ file = serverRoot.getFile("/tests/dom/tests/mochitest/general/frameStoragePrevented.html");
+ });
+
+ // Set up the file streams to read in the file as UTF-8
+ let fstream = Components.classes["@mozilla.org/network/file-input-stream;1"].
+ createInstance(Components.interfaces.nsIFileInputStream);
+ fstream.init(file, -1, 0, 0);
+ let cstream = Components.classes["@mozilla.org/intl/converter-input-stream;1"].
+ createInstance(Components.interfaces.nsIConverterInputStream);
+ cstream.init(fstream, "UTF-8", 0, 0);
+
+ // Read in the file, and concatenate it onto the data string
+ let data = "";
+ let str = {};
+ let read = 0;
+ do {
+ read = cstream.readString(0xffffffff, str);
+ data += str.value;
+ } while (read != 0);
+
+ // Write out the file as a data: URI, and redirect to it
+ response.setStatusLine('1.1', 302, 'Found');
+ response.setHeader('Location', 'data:text/html,' + encodeURIComponent(data) + "#nullprincipal");
+}