From 2aa4a82499d4becd2284cdb482213d541b8804dd Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 28 Apr 2024 16:29:10 +0200 Subject: Adding upstream version 86.0.1. Signed-off-by: Daniel Baumann --- dom/fetch/tests/.eslintrc.js | 5 ++ dom/fetch/tests/browser.ini | 2 + dom/fetch/tests/browser_blobFromFile.js | 62 ++++++++++++++++++++++ dom/fetch/tests/crashtests/1577196.html | 26 +++++++++ dom/fetch/tests/crashtests/1664514.html | 6 +++ dom/fetch/tests/crashtests/crashtests.list | 2 + dom/fetch/tests/crashtests/url.url | 5 ++ dom/fetch/tests/mochitest.ini | 2 + dom/fetch/tests/test_ext_response_constructor.html | 46 ++++++++++++++++ dom/fetch/tests/test_invalid_header_exception.html | 39 ++++++++++++++ 10 files changed, 195 insertions(+) create mode 100644 dom/fetch/tests/.eslintrc.js create mode 100644 dom/fetch/tests/browser.ini create mode 100644 dom/fetch/tests/browser_blobFromFile.js create mode 100644 dom/fetch/tests/crashtests/1577196.html create mode 100644 dom/fetch/tests/crashtests/1664514.html create mode 100644 dom/fetch/tests/crashtests/crashtests.list create mode 100644 dom/fetch/tests/crashtests/url.url create mode 100644 dom/fetch/tests/mochitest.ini create mode 100644 dom/fetch/tests/test_ext_response_constructor.html create mode 100644 dom/fetch/tests/test_invalid_header_exception.html (limited to 'dom/fetch/tests') diff --git a/dom/fetch/tests/.eslintrc.js b/dom/fetch/tests/.eslintrc.js new file mode 100644 index 0000000000..1779fd7f1c --- /dev/null +++ b/dom/fetch/tests/.eslintrc.js @@ -0,0 +1,5 @@ +"use strict"; + +module.exports = { + extends: ["plugin:mozilla/browser-test"], +}; diff --git a/dom/fetch/tests/browser.ini b/dom/fetch/tests/browser.ini new file mode 100644 index 0000000000..8705dea1ab --- /dev/null +++ b/dom/fetch/tests/browser.ini @@ -0,0 +1,2 @@ +[DEFAULT] +[browser_blobFromFile.js] diff --git a/dom/fetch/tests/browser_blobFromFile.js b/dom/fetch/tests/browser_blobFromFile.js new file mode 100644 index 0000000000..155f420477 --- /dev/null +++ b/dom/fetch/tests/browser_blobFromFile.js @@ -0,0 +1,62 @@ +add_task(async function test() { + await SpecialPowers.pushPrefEnv({ + set: [["browser.tabs.remote.separateFileUriProcess", true]], + }); + + let fileData = ""; + for (var i = 0; i < 100; ++i) { + fileData += "hello world!"; + } + + let file = Cc["@mozilla.org/file/directory_service;1"] + .getService(Ci.nsIDirectoryService) + .QueryInterface(Ci.nsIProperties) + .get("ProfD", Ci.nsIFile); + file.append("file.txt"); + file.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0o600); + + let outStream = Cc[ + "@mozilla.org/network/file-output-stream;1" + ].createInstance(Ci.nsIFileOutputStream); + outStream.init( + file, + 0x02 | 0x08 | 0x20, // write, create, truncate + 0666, + 0 + ); + outStream.write(fileData, fileData.length); + outStream.close(); + + let fileHandler = Cc["@mozilla.org/network/io-service;1"] + .getService(Ci.nsIIOService) + .getProtocolHandler("file") + .QueryInterface(Ci.nsIFileProtocolHandler); + + let fileURL = fileHandler.getURLSpecFromFile(file); + + info("Opening url: " + fileURL); + let tab = BrowserTestUtils.addTab(gBrowser, fileURL); + + let browser = gBrowser.getBrowserForTab(tab); + await BrowserTestUtils.browserLoaded(browser); + + let blob = await SpecialPowers.spawn(browser, [file.leafName], function( + fileName + ) { + return new content.window.Promise(resolve => { + content.window + .fetch(fileName) + .then(r => r.blob()) + .then(blob => resolve(blob)); + }); + }); + + ok(blob instanceof File, "We have a file"); + + is(blob.size, file.fileSize, "The size matches"); + is(blob.name, file.leafName, "The name is correct"); + + file.remove(false); + + gBrowser.removeTab(tab); +}); diff --git a/dom/fetch/tests/crashtests/1577196.html b/dom/fetch/tests/crashtests/1577196.html new file mode 100644 index 0000000000..a2cdae06d0 --- /dev/null +++ b/dom/fetch/tests/crashtests/1577196.html @@ -0,0 +1,26 @@ + + + + + + diff --git a/dom/fetch/tests/crashtests/1664514.html b/dom/fetch/tests/crashtests/1664514.html new file mode 100644 index 0000000000..dae325d2a7 --- /dev/null +++ b/dom/fetch/tests/crashtests/1664514.html @@ -0,0 +1,6 @@ + + +

Set privacy.file_unique_origin to false when testing this.

+ diff --git a/dom/fetch/tests/crashtests/crashtests.list b/dom/fetch/tests/crashtests/crashtests.list new file mode 100644 index 0000000000..b3210cd4d8 --- /dev/null +++ b/dom/fetch/tests/crashtests/crashtests.list @@ -0,0 +1,2 @@ +load 1577196.html +pref(privacy.file_unique_origin,false) load 1664514.html diff --git a/dom/fetch/tests/crashtests/url.url b/dom/fetch/tests/crashtests/url.url new file mode 100644 index 0000000000..95e9cf8db0 --- /dev/null +++ b/dom/fetch/tests/crashtests/url.url @@ -0,0 +1,5 @@ +[{000214A0-0000-0000-C000-000000000046}] +Prop3=19,11 +[InternetShortcut] +IDList= +URL=http://localhost:8000/ diff --git a/dom/fetch/tests/mochitest.ini b/dom/fetch/tests/mochitest.ini new file mode 100644 index 0000000000..32eb841faf --- /dev/null +++ b/dom/fetch/tests/mochitest.ini @@ -0,0 +1,2 @@ +[test_ext_response_constructor.html] +[test_invalid_header_exception.html] diff --git a/dom/fetch/tests/test_ext_response_constructor.html b/dom/fetch/tests/test_ext_response_constructor.html new file mode 100644 index 0000000000..adff6c78e9 --- /dev/null +++ b/dom/fetch/tests/test_ext_response_constructor.html @@ -0,0 +1,46 @@ + + + + + Test `Response` constructor in a WebExtension + + + + + + +

+ +

+
+
diff --git a/dom/fetch/tests/test_invalid_header_exception.html b/dom/fetch/tests/test_invalid_header_exception.html
new file mode 100644
index 0000000000..274e85bb68
--- /dev/null
+++ b/dom/fetch/tests/test_invalid_header_exception.html
@@ -0,0 +1,39 @@
+
+
+
+
+  Test for Bug 1629390
+  
+  
+  
+  
+
+
+Mozilla Bug 1629390
+

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