A few months ago while developing application for Chromecast and Android devices I have used
window.location.reload(true)
a lot. It was used to reload JavaScript and images in Receiver.
Recently I got back to develop app and now when I use this command, I get undefined in console. Nothing reloads, Sender still can communicate with Receiver. I launch this command again and then, debug is detached, Chromecast crashes and it needs to be reloaded...After it reloads, I launch Sender which launches Receiver and still cache is not cleared. So I use command again and it works. But only one time. Second time, the same situation.
Any ideas what is wrong?
My Chromecast uses 220620 firmware version.
EDIT
Further investigation. Problem appears when I don't do anything for some time, for instance 50 seconds. If I do it right away or in a few seconds, it's OK.
Maybe it could be the timeout when debugging. Try to add the following in your js:
castReceiverManager.start({maxInactivity: 600});
And that will wait 10 minutes.
I was reading this question again, and I should say that what I use the most is to just hit F5 on devtools. Also make sure you have the option "Disable cache (while DevTools is open)" enable for better results.
Related
PgAdmin in the latest version (4.28) doesn't start anymore, hangs in the loading screen and shows JavaScript errors in the browser console. What can I do?
The solution is simple although I don't really know why it occurs from that version on:
Open the registry editor (Search for regedit.exe)
Run it as administrator
Navigate to Computer\HKEY_CLASSES_ROOT\.js
Adjust Content Type from text/plain to text/javascript
Restart pgAdmin and it should work again.
Maybe, you will have to clean your browser cache or restart your computer as well (Thanks to the Kassym and Bruce).
As already I said, I have no idea why or how this happens, maybe someone from the team can add this as a comment here and I will update my answer.
I would like to know, whether I'm currently debugging my javascript code?
Background: (Why I need to know)
I have created a page, that spawns a Worker.
When I run this page and press F12 to debug, I set a breakpoint in the Worker. This breakpoint will then get hit when I press my button to run the Worker (so far all good).
Now to prevent that the Worker runs forever I have created a simple timer in the main page, that terminates the Worker after 2 seconds, like this:
timer = setTimeout(function ()
{
worker.terminate();
worker = NewWorker();
}, 2000);
Now the problem: When the breakpoint is hit in Worker, the timer fires 2 seconds later (since the main page thread is still running independantly) and terminates the Worker. So I can't debug the Worker.
My plan is to simply disable (or not start) the timer, when I'm debugging.
So, Is there a way to know, if a debugger is attached?
Update:
My current workaround is to simply comment out the timer code, when I want to debug the Worker, but I would like to do a test.
Update2:
May be a debugger is always attached in the browser, but it's only active when it's visible. Breakpoints are only hit when you have the debugger window open.
So, is there a way to test that?
Well, it seems, there's no answer to this question.
Ideally I would want the browser to break all threads when one thread hit a breakpoint (Visual Studio can do this, but not in javascript).
May be one day browsers will support this.
Update:
Now Visual Studio supports debugging Worker. It's still an experimental feature. You enable it using the weirdly named option in 'Options', 'Debugger':
Enable using the multi-target Javascript debugger for debugging Javascript in applicable targets (requires debugging restart)
To debug a Worker, start debugging your page, then Visual Studio Solution Explorer will show show the Worker.js file. double-click and breakpoints.
However it has not really solved the problem with timers in the main thread firing when you hit a breakpoint in a Worker.
I am working on a project. The project is about developing a new extension for Google Chrome. Well everything works fine, but out of curiosity, I came to a question, if you could restart Chrome browser, after you installed your extension?
I have been looking around the internet and didn't get much success from it. Is there any Javascript code for it?
I tried with those bellow, but with no success.
chrome.tabs.create({ 'url': 'chrome://restart'});
chrome.send('restartBrowser');
window.location = 'chrome://restart';
I thank you in advance!
No, allowing JavaScript to restart the browser would be a risk. Imagine if you open a malicious page that restarts the browser once it opens up, this would put it in an infinite loop where the browser keeps on restarting itself.
I've developed some Chrome apps and Chrome extensions these day for fun.
and I'm wondering if I can schedule launch Chrome app and run certain commands periodically like cron jobs.
I know Chrome provide "chrome.alarm api" to run a certain function periodically, but I believe it requires users to keep my chrome app open or to keep chrome browser open which my chrome extension is installed to.
Please tell me if I can do such a thing in the first of all, and if I can do, please tell me how I can accomplish that!
A Chrome App doesn't have to be running to use the chrome.alarms API. See https://developer.chrome.com/apps/alarms for details about how to use it.
Basically, here's how it works:
// background page (aka event page)
chrome.alarms.onAlarm.addListener(function() {
// Do something useful...
});
// Register an alarm that will wake my background page every hour.
chrome.alarms.create('', { periodInMinutes: 60 });
For info, here are some good Chrome App samples that use chrome.alarms at https://github.com/GoogleChrome/chrome-app-samples/search?utf8=%E2%9C%93&q=alarms
A Chrome Extension can stay active even before/after Chrome is launched, unless the user specifically forbids that. Kind of like Google Now operates in recent Chrome versions.
For that, you need to declare "background" permission.
Makes Chrome start up early and and shut down late, so that apps and extensions can have a longer life.
When any installed hosted app, packaged app, or extension has "background" permission, Chrome runs (invisibly) as soon as the user logs into their computer—before the user launches Chrome. The "background" permission also makes Chrome continue running (even after its last window is closed) until the user explicitly quits Chrome.
I'm afraid it's not an option for a Chrome App though. The wording in the documentation refers to deprecated legacy app types. See François's answer for a possible solution in Apps.
I would love to see things on the console but nothing shows up.
This is logging in javascript.
I have instead used the echo command and that helps for a while but I really need to be able to log and see what I log.
I've tried creating a new logger object even.
This may in fact not be a selenium issue but how firefox is set up.
Also, Logging does work when I am playing back, it is not working when I am recording.
I do have firebug and firepath installed and I still don't see anything unless I don't now where to look.
This is not related to the version of Firefox.
The only way to see logging to during recording is to first play something back. Therefore, if you open the Selenium window and immediately start recording commands, logging for that activity is lost until at least one command is played back. E.g., record a command, then double click it, (even if that results in an error), then continue recording. Now you will see logging for subsequent recording.
This is probably the single most irritating deficiency with the Selenium IDE.