Kill a tab on "Unresponsive Script" - javascript

Please pardon my ignorance, relatively new to working with XULRunner.
I'm attempting to debug an issue with a XULRunner application and have hit a wall. We're using the app to load certain websites and retrieve layout information. After the scrape is done, we close the tab that the page has been loaded in. Occasionally, the number of tabs will grow continuously until memory is exhausted. Our theory is that the browser is hitting an unresponsive script which blocks execution indefinitely.
Is there a preference that can be set or something that will automatically kill tabs that hit an unresponsive script?
I've Googled around and the only thing I can find is
dom.max_script_run_time
which only allows you to specify how long to wait before popping up the "Unresponsive Script" dialog, but doesn't actually kill the tab.

I'm not totally sure I understand, but here are my thoughts: You could run the script in a separate process, and then kill that process if it takes too long. Or you could have the script continuously check out long it's been running and then kill itself if it takes too long. Other than that I don't know what you could do.

Related

Firefox not completing page load after click sent by selenium on sauce

A test which works perfectly well locally with selenium webdriver is timing out when run remotely on saucelabs.com. The same test works for Chrome (both local and on sauce).
From the client code's side, the click in the following code is never returning:
var someLink = await driver.findElement(By.className('some-class'));
await someLink.click()
I'm using jest for the test framework with at 60 second timeout, so on the client end, I get that timeout error after a minute.
When I log into sauce and look at the list of commands it processed I see:
POST elements
With parameters:
{"using":"css selector","value":".some-class"}
And the returned body is:
[{"ELEMENT":"2"}]
So that succeeds and finds the link. I then never see a click event on that element. Prior click events, and navigation commands are successful.
When I watch the video playback of the session, I see it click the given link and the new page load in Firefox, but the spinner (actually a little dot going back and forth) in the top right never stops.
I can't reproduce with Firefox myself, or even through the manual testing on Saucelabs where you can control the browser and VM through the web.
I'm wondering if there's some synchronous code that's running that just isn't resolving. But I can't figure out how to find that out. The developer tools don't appear to have any way to show currently blocking code.
When page is being loaded, Selenium is waiting for document.readyState to be complete.
Sometimes loading of some resource might stuck - when it tries to get big file and connection is poor, when resource is not reachable because of proxy, when service that provides this resource is down, and so on.
I had the same problem with Firefox and solved it using eager page load strategy.
With this load strategy Selenium will wait for document.readyState to be interactive - some resources might not be loaded, but main elements of the page are loaded and you can interact with them in common way.
DesiredCapabilities caps = DesiredCapabilities.firefox();
caps.setCapability(CapabilityType.PAGE_LOAD_STRATEGY, "eager");

Is there really no way to auto-kill unresponsive scripts in Firefox?

So, in our development team we have a computer attached to a big screen. This computer is used as a dashboard. It's running Firefox in full-screen 24/7. It's automatically rotating all open tabs every few minutes and it's automatically reloading these tabs. It's not a huge amount of tabs, currently only 3.
The problem is that every now and then a script on one of these tabs goes completely wild and totally freezes the entire computer. So it takes roughly 10 minutes to kill Firefox's process and restart it. This is really annoying. It happens every few days.
The content (applications) which these tabs show are not under our control, we can't change anything about them. Our only option is to adapt to them as best as possible.
What I want to do is to make Firefox, instead of showing the "unresponsive script" prompt, to automatically kill the script, without the need for any interaction from the user. I don't care if the script is killed. It's only used to render the page and the page will be reloaded in a few minutes anyway.
The thing is that this "freezing" usually happens over night, slowly consuming the computer's resources more & more, so when we come in the morning it's really frozen deep. Like, just hitting ctrl+alt+f1 to bring up a terminal and log in takes several minutes.
I've googled my ass off trying to find a solution for this, but so far I didn't find any. I want it to simply work for like a month without the need for any intervention.
You could run with e10s enabled (available in dev edition) and write an addon that instruments tabs and periodically sends messages to them. if they don't respond within a certain timespan you can kill the content process, close all tabs and reopen them.
Since you say it hangs the entire computer you could also limit the memory available to the process and just restart it via a script when it gets killed due to OOM.

Create shortcut, that opens a website and reload it after x ms

We've just upgraded group policies at work because of a big migration project. Nevermind... The thing is, some of our users use this java application, which reads the smart card reader. On new machines it doesn't work in IE, it has to run in firefox. The trouble is, that the first time firefox opens it, it says there's no java. As soon as you reload it, it's fine.
As users are users, they hate the thought of having to reload the page, and it's not very elegant either. As the process of upgrading anything in the company is difficult, and I'm only an entry level desktop support guy, it won't get fixed any time soon.
So I was thinking... is there any way to create a shortcut, that would open the page and then reload it once it finishes loading the first time?
It can be a shortcut to a local html file which then redirects it to the final location...
You can use a vbs:
set WScriptShell = CreateObject("WScript.Shell")
WScriptShell.Run("http://www.facebook.com/")
WScript.Sleep(2000)
WScriptShell.SendKeys "{F5}"
This one opens a page in the browser, waits 2000 ms (probably enough for the page to load) and then sends the "F5" key to the currently active window. This may not be a perfect solution, but you can extend it to match your needs.
Have you tried $( document ).ready() and insert the code in this function? This basically waits your whole page to load and after that executes the code in the function.

Javascript timer puzzle

This is a weird scenario I just experienced and I am not sure how to phrase the question.
It may be best to describe my application and what it does 1st.
I have an IP camera connected to my router.
I use a C# VLC wrapper to get 10 frames a second using a RTSP protocol.
I then upload to my web server using a [web method] these seperate jpegs to my server.
Then via browser using a javascript timer set to 100ms it renders the image into a HTML image control by calling an ashx page repteadly.
Now this has worked for a few days OK.
Now this is what I have experienced in the last 48hrs.
The images coming from the IP Camera was jumpy. That is to say sometimes the images flow in a timely order and sometimes it will slow down, stop and speed up again to 'catch up'.
I noticed when viewing via a web browser client on another PC on my network that the javascript timer calls were slow and sometimes stopped for periods of time. I used Google Chrome to view how often the ashx url was being called.
I closed down my own applications. Rebooted all my PCs and started VLC application without using the wrapper. Again, the flow was 'jumpy'. So the conclusion there was that it was not my application.
For some reason I decided to log into my router (192.168.0.1).
Page was not found.
In fact I had to do a complete restart of my router to be able to access my router 'page'.
As soon as I did this everything worked OK again.
So, the 2 questions I have is (1) why could I not access my router through that IP address and (2). Why was my javascript timer crashing to a stand-still?
Like I said this is a weird scenario and I would not blame anyone for wanting to close or vote down this question.
But on the off-chance this is a known thing I would like to be educated.
Thanks

how to handle javascript loading error in web application which uses facebook javascript sdk

I am integrating a web application with facebook by following this tutorial
It is normally working but when AVG do not track is active the browser can't load the Facebook JavaScript SDK so I want to show the user that in such a case he needs to disable the AVG do not track for the current website..
Is there a way to handle the loading error in JavaScript? We have try catch in Java - is there something similar in JavaScript so that I can hadle the loading error.
Sorry if this is a simple question ... I am a noob when it comes to JavaScript :(
I attached a little function to give feedback at the end of the code supplied by the tutorial.
http://jsfiddle.net/PRvJs/1/
The problem is that because your script is running in a web app and the blocking is happening on the browser application level, you can only ever infer that things have gone awry, and even then you have to make assumptions – scripts have load and error events but most Facebook blocking scripts circumvent that whole thing and just kill the HTTP request before it even goes out… so you can never really know!
As a fallback, I made the subjective decision to wait 30 seconds and if there is still no load or error resolution to the script injection, makes the arbitrary [1] decision that something is fundamentally screwed somewhere between your code and Facebook. As far as I know, this is the most you can determine and the only way to determine it…
[1] Most connections close if nothing has happened in 30 seconds.

Categories