Firefox extension can not download files from whatsapp web
Categories
(WebExtensions :: Untriaged, defect)
Tracking
(firefox89 affected, firefox90 affected, firefox91 affected)
People
(Reporter: andrey2013, Unassigned)
Details
Attachments
(3 files)
User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.77 Safari/537.36
Steps to reproduce:
In the code of the browser extension (background.js):
- Add listener to downloads.onCreatedEvent
browser.downloads.onCreated.addListener((downloadItem)=>{... - Try to download the file from the url downloadItem.url via the following simple code:
var xhr = new XMLHttpRequest();
xhr.open("GET", download.url, true);
xhr.withCredentials = true;
xhr.timeout = 1000000;
xhr.responseType = "arraybuffer";
xhr.onload = function() {
console.log('on load');
}
xhr.ontimeout = function(e) {
console.log('on timeout');
}
xhr.onerror = function(e) {
console.log('error');
console.log(e);
}
xhr.onprogress = function(evt) {
console.log(evt);
}
xhr.onreadystatechange = function() {
console.log('onreadystatechange');
}
xhr.send(); - Enter whatsapp web and try to download an attached document
Actual results:
When background.js will try to download the file, the following error will be shown:
Security Error: Content at moz-extension://.../_generated_background_page.html may not load data from blob:https://web.whatsapp.com/...
The same error occurs if I do F12 in whatsappweb.com and I try to run that code from the console:
Security Error: Content at https://web.whatsapp.com/ may not load data from blob:https://web.whatsapp.com/d29b58ca-5d29-4355-9e04-bb575d7ce872.
Expected results:
The ajax request which is used to download the file should work
Comment 1•3 years ago
|
||
The Bugbug bot thinks this bug should belong to the 'WebExtensions::Untriaged' component, and is moving the bug to that component. Please revert this change in case you think the bot is wrong.
Comment 2•3 years ago
|
||
Hello,
I’ve attempted to reproduce the issue, however I’m having some trouble with building a working extension. Could you please attach the test extension you used here?
Furthermore, as per the actual results, I’ve tried accessing a conversation on whatsappweb.com which has several attachments, opening the web console (F12) and running the code from Step 2. Nothing happens, except for a reference error being printed in the console (Uncaught ReferenceError: download is not defined
).
I’ve also tried accessing an attachment from said conversation and running the code and opening the attachment in a new tab and running the code. Nothing happens once more in both cases, except for the reference error.
Could you provide some more specific steps to reproduce?
Thank you !
Comment 3•3 years ago
|
||
Could you share reproduction steps, consisting of an extension and a publicly available test page, independent of Whatsapp web?
A simple extension in which the issue can reproduced
Hello,
The issue can be reproduced in the attached simple extension (simple_extension.zip which contains only basic code that is relevant for the bug. Please load it via about:debugging).
Unfortunetly, I don't know how to reproduce it outside whatsapp web. I suspect that the problem is with download in which the url of the download starts with blob:.. and i'm not fimiliar with other sites that use such links.
I also attached background_console.png.
After I loaded simple_extension.zip and pressed "Inspect" and got to the console of the background.
This is the image after the issue was recreated.
You can see there the following error:
Security Error: Content at moz-extension://b9ca3200-8f06-4ac1-bfb5-dc2faf7ebbd0/_generated_background_page.html may not load data from blob:https://web.whatsapp.com/f7be7816-e611-4621-b748-cf3e1d985f6d.
Thank you very much for your assistance.
Comment 8•3 years ago
|
||
Hello and thank you for the additional info and extension !
I reproduced the issue on the latest Nightly (91.0a1/2021061421540), Beta (90.0b7/20210613190011) and Release (89.0/20210527174632) under Windows 10 x64 and Ubuntu 16.04 LTS.
Attempting to download an image from whatsapp web while the test add-on is loaded will produce the mentioned error in the console. For further details, please see the attached screenshot.
However, I would like to mention that I could download the image in question using “Save Image As…” from the right click context menu or by using the whatsapp download button on the page.
Comment 9•3 years ago
|
||
Updated•3 years ago
|
Comment 10•2 years ago
|
||
The behavior is expected. There are two potential reasons for the observed error:
- The page does not have permission to request the requested blob:-URL.
- The requested blob URL no longer exists.
When you request a blob:https...
URL from an extension page, the request is expected to fail because blob:
-URLs can only be requested by the origin that created the URL.
The same error occurs if I do F12 in whatsappweb.com and I try to run that code from the console:
This is probably issue 2.
Description
•