Is there any way to load background js even on error pages (such as net::ERR_NETWORK_CHANGED)? I need to keep persistence connection with WS server from the extension, but error pages don't load background js. So I lose the connection and possibility to restart it (due this is automated tool without access to browser ui).
The only solution I found is to use proxy server to customize error pages and load background js inside of them.
The assertion "Background js doesn't work on error pages" does not make any sense, because there's only one background page per extension two if you use split incognito mode.
So I assume that you want to detect a network connectivity loss in order to restore the web socket. Chrome offers two reliable global events for this: online and offline.
I have published the source code of Real-time desktop notifications for Stack Exchange inbox, which also accounts for network connectivity loss/regain. The relevant Web Socket part of the Chrome extension is found in stackexchange-notifications/Chrome/using-websocket.js on Github.
Related
I am currently trying to enable remote inspector for a OpenJFX web view component in order to be able to debug javascript code interactions with the Java part of the application. This is why I cannot debug the web part in a standalone browser.
There appears to be no detailed documentation related to remote inspector besides a few fixed scenarios which have pre-configured solutions available. Based on reverse-engineering and other research, I was able to piece together the following:
I have obtained an instance of Debugger interface out of the OpenJFX WebEngine instance;
I have created a simple TCP server which communicates with the WebKit browser using its protocol (eg. messages like "SetupInspectorClient", "GetTargetList", "SendMessageToBackend", etc.). This is enough to make the remote WebKit browser recognize my view when opening the inspector://localhost:<port> URI;
When attempting to connect to a particular view, the majority of the communication is handled by the "SendMessageToBackend" and "SendMessageToFrontend" messages forwarded by my code between remote WebKit browser and the Debugger instance. However, based on communication traces the only response that the remote browser receives to its requests is a "'Target' domain was not found" and "'Browser' domain was not found" errors.
I presume the above problem may be caused by either incompatible webkit versions between OpenJFX and my remote browser - although I am using WebKit 613.1 on both ends. Other possibility is that the OpenJFX uses some sort of stripped-down WebKit which does not support the inspector commands at all. However, I don't know enough about WebKit to be able to find it out on my own.
Is it possible to get remote inspector working in OpenJFX 17, and if yes, then how?
I used xcrun safari-web-extension-converter to convert my chrome extension to safari extension but it built with this warning
Warning: Persistent background pages are not supported on iOS and iPadOS. You will need to make changes to support a non-persistent background page.
Also when using it on safari, it is showing these errors:
Extension errors in safari
How can I debug the errors in the extension? I'm not sure about the error but the persistent page warning seems to be a good place to start with. While searching for it in google, all I got is results for non-persistent background pages.
Do let me know if any more information is required.
PS:
The extension option in the "develop" menu of safari is also disabled due to service_worker failed to load error.
From WWDC21-10104:
The background page is a web page that the browser loads to run your
extension's background script. And this page allows your extension to
handle events sent by the browser or other parts of your extension.
But keeping this page loaded has a performance cost. It can use memory
and power as if you were keeping one more tab open and running for
every enabled extension. Keeping all these pages loaded all the time
can be pretty wasteful. But you can make a background page
non-persistent, which means the browser will only load it when your
extension actually needs to do work, and the browser can later unload
that page when it's been idle for some time. That way, the performance
cost is only paid while your extension is doing something useful. This
is important because background pages must be non-persistent on iOS,
where system memory and battery life are especially at a premium. The
web extension templates in Xcode already come with a non-persistent
background page, so they're ready to run on iOS. But if you have an
existing extension that uses a persistent background page like Sea
Creator did, you'll need to change it to be non-persistent. And you
can do that by adding that "persistent:" False key in the background
section of your manifest.
So you can solve it by adding this to your manifest.json:
"background": {
"scripts": [ "background.js" ]
"persistent": false
}
Using MS Edge and apache w/ php, I just discovered via access.log that when I have the JavaScript debug panel (i.e. developer panel) open, it is making every http call twice. When I closed this panel, it has fixed the issue of all insert statements getting called twice.
Question: Does this doubling of http calls happen on every / most browsers that I need to look out for, or is this something special/unique with MS Edge?
I can't speak for all browsers and all developer tools. But, for IE and Edge the first time you open the tools and then open a JS file in the sources view it will try to request the file again. That request will be served from the local browser cache, sometimes not, depending on the cache settings for the file being requested.
The reason browser tools need to make this request is that browsers will often throw out the original source file as it doesn't need it to execute the page, as the source has been parsed it into something else that it can work with.
However, after you've opened the developer tools the browser will keep around sources in future navigations, either in the tools front end or elsewhere. Not keeping sources is an optimization for the first time use case, to save browsers keeping around source on the very low odds of the tool being used on any given navigation.
Of course some files are never cached by the browser and will need to be downloaded when requested by the tools, for example sourcemapped files.
In general any resources on your site that can be accessed by HTTP GET should be idempotent. That is, a GET shouldn't change the resource being requested (or generall the state of your site), so hopefully making additional requests shouldn't be an issue.
My iOS application, among its features, download files from a specific server. This downloading occurs entirely in the background, while the user is working on the app. When a download is complete, the resource associated with the file appears on the app screen.
My users report some misbehavior about missing resources that I could not reproduce. Some side information leads me to suspect that the problem is caused by the download of the resource's file to be aborted mid-way. Then the app has a partially downloaded file that never gets completed.
To confirm the hypothesis, to make sure any fix works, and to test for such random network vanishing under my feet, I would like to simulate the loss of the network on my test environment: the test server is web sharing on my development Mac, the test device is the iOS simulator running on the same Mac.
Is there a more convenient way to do that, than manually turning web sharing off on a breakpoint?
Depending on how you're downloading your file, one possible option would be to set the callback delegate to null halfway through the download. It would still download the data, but your application would simply stop receiving callbacks. Although, I don't know if that's how the application would function if it truly dropped the connection.
Another option would be to temporarily point the download request at some random file on an external web server, then halfway though just disconnect your computer from the internet. I've done that to test network connectivity issues and it usually works. The interesting problem in your case is that you're downloading from your own computer, so disconnecting won't help. This would just be so you can determine the order of callbacks within the application when this happens, (does it make any callbacks at all? In what order?) so that you can simulate that behavior when actually pointed to your test server.
Combine both options together, I guess, to get the best solution.
I have mobile web application that has offline capabilities (via HTML5).
I'm currently building automatic build & testing for it (ant, JsTestDriver etc.), until I hit a wall. How can I test if the web application has working offline mode? This is specially painful since if tested by hand; iPhone practically needs full reset between tests (it tends to cling on to some parts of the data).
I'm thinking something around these lines (on a idea level):
Setup Java web server with ant
Fire some sort of headless client, that supports HTML5 offline use
Load the application
Validate that everything is loaded
Disable server
Load the application
Validate that everything is loaded, still
Any suggestions how would I proceed doing something like this?
Not sure I understand your question, but what do you think of:
Not using an iPhone, but chrome on PC with the ripple emulator http://ripple.tinyhippos.com/
Setting a fake proxy or editing the .host file in order to be sure that your chrome session does not have access to your server.