I can't seem to find this problem anywhere else and I'm getting frustrated with it. Basically, I have whitelisted my device successfully and I am starting to develop a simple 'Hello World' application using Chrome as my sender. I went in and I whitelisted localhost in the Chromecast extension and added data-cast-api-enabled="true" to the html tag of my sender page. It even seems as if the extension is trying to inject the API.
But, in the Chrome debugger I get an error: Uncaught SyntaxError: Unexpected token ILLEGAL
I looked in the network tab and saw that api_script.js was coming in from the extension and I could even open it in a separate tab. But, for some reason this page is interpreting this javascript file as...well, what appears to be Japanese. In the network tab, the response for the request for api_script.js is (and this is just abbreviated):
....慶慣瑳㴠挠獡⁴籼笠㭽挊獡䅎䕍㴠∠慃瑳灁≩慣瑳嘮剅䥓乏㴠嬠ⰲ㐠㭝挊獡敒散癩牥㴠映湵瑣潩⡮摩慮敭
桴獩椮‽摩†桴獩渮浡‽慮敭†桴獩椮味扡牐橯捥整‽桴獩椮䅰摤敲獳㴠渠汵੬㭽挊獡慌湵档敄捳楲瑰潩‽畦据
湯⤨笠 琠楨牵‽桴獩琮硥⁴‽畮汬紊慣瑳䰮畡据剨煥敵瑳㴠映湵瑣潩⡮捡楴楶祴祔数敲散癩牥
†桴獩愮瑣癩瑩呹灹
‽捡楴楶祴祔数†桴獩爮捥楥敶‽敲散癩牥†桴獩搮獥牣灩楴湯㴠琠楨慰慲敭整獲㴠渠汵㭬 琠楨楤捳湯敮瑣潐楬
㴠∠潣瑮湩敵ਢ...
I'm not really sure why this is happening. It seems like copying the API code directly into my webpage is the only way I can get this thing working at all. Does anyone have any insight on this?
Chromecast is interpreting your script as UTF-16 (as proof, I pasted that garbage and saved it as UTF-16-LE, and got a text file starting with var cast = cast || {};).
Make sure you don't have a BOM header on the script. If the problem is due to charset detection, try adding some extended-ASCII characters in a comment near the beginning to force charset detection to pick e.g. UTF-8.
Related
For our application we extract decoded params from the encoded url, like "Café Boss", and perform an api call to our backend to fetch the data for that restaurant.
This all has been working perfectly for the past year, but since this week we seem to have trouble with restaurant names that have special characters like "é". We see a "400 bad request" error and "HttpErrorResponse" in the inspect module of the browser.
This only happens in production with Chrome 89.0.4389.116 and works fine on older version and other browsers. When I run the same code in localhost it runs perfectly. I console logged the params we extract, and in all browsers they are exactly the same. The request headers are also exactly the same.
Since this seems to be a problem solely exclusive to the newest version of Chrome, I believe this is a bug within Chrome itself. However, I may be wrong and I'm hoping someone had the same problem and can offer a solution.
I bypassed this problem by encoding the restaurant name with encodeURI before passing it to the headers and by decoding it in the backend.
I am learning node and wrote a simple app which returns just JSON data as response.
There is no any error but I am not getting why there are 5 different resources (content.min.css, favicon.ico, jsonview-core.css, options.png, etc) showing in my network tab. Can anyone help me to understand this.
If possible how can I avoid sending these extra resources and just send the JSON data?
It's because of the chrome extension that I am using.
I found some interesting about favicon.ico file:
Modern browsers will show an icon to the left of the URL. This known
as the 'favicon.ico' and is typically fetched from
website.com/favicon.ico. Your browser will automatically request it
when browsing to different sites. If your browser receives a valid
favicon.ico file, it will display this icon. If it fails, it will not
display a special icon.
I am working on a website on my localhost and suddenly I'm now getting this errors.
I get this error on Firefox
<script> source URI is not allowed in this document
And nothing on chrome,` but if I try using the files code, I get:
Application Error: There was a problem getting data for the application you requested. The application may not be valid, or there may be a temporary glitch. Please try again later.
It is basically for: https://connect.facebook.net/en_US/sdk.js.
The browser doesn't even send a GET request for the file.
Everything used to work perfect before. Not sure why I'm getting this.
I had an extension installed on both of my browsers. It was preventing it from loading.
If you have any VPNs, hide-tracking extensions, then it needs to be disabled.
In my case it was Disconnect firefox/chrome extension.
I have found no joy in getting any of the sample programs for Chrome to connect to my Chromecasts.
The Chromecasts have been registered and I am able to browse to their IP address port 9222 successfully.
Both the Chrome browser and Beta extension are up to date.
I have tried the CastHelloVideo-Chrome, CastMedia-Chrome and Cast-Tictactoe-Chrome and all fail to connect. The developer console shows a pair of errors:
GET chrome-extension://boadgeojelhgndaghljhdicfkmllpafd/cast_sender.js net::ERR_FAILED
and
Failed to execute 'postMessage' on 'DOMWindow': The target origin provided ('file://') does not match the recipient window's origin ('null').
When testing our own code we get an error when calling requestSession but the message returned by Chrome.cast.Error is useless since the function and variable names have been obscured.
I also have a difficult time testing the examples for Chrome. I decided to use Chrome to test because debugging JavaScript is so much quicker than going directly to Android. I spent hours trying to figure out why I keep getting the error message GET chrome-extension://boadgeojelhgndaghljhdicfkmllpafd/cast_sender.js net::ERR_FAILED and Failed to execute 'postMessage' on 'DOMWindow': The target origin provided ('file://') does not match the recipient window's origin ('null') if I run it from my PC but not when I run it from an example website at http://www.videws.com/eureka/helloVideos/ provided by one of the Cast developers at Google. I keep reading/trying different combinations from his readme note in the example until it dawned on me what he meant by "Put all files on your own server" instead of "computer".
I created a public weblink on my Google Drive, make the folder public and copied all the files there. When go to Google drive on the web, preview the example (index.html), the example runs beautifully. I tried tic-tac-toe. It also runs.
So the answer is you need to run it off a website -- not from a local file in your computer (ctrl-O in Chrome)
I hope this will help you going with Cast.
Danh
I was finally able to get connected, but from Android. Many steps will be the same though.
I tested this: https://github.com/googlecast/CastHelloText-android It let's you speak into the phone, and what you say appears on the TV/Chromecast. I didn't install the formal sender app, but I was able to load the TicTac Toe from the receiver as well. So i have seen them both on my CC.
I couldn't connect until I properly setup the RECEIVER APPLICATION. You didn't mention it.
What I did from where I think you are at.. I just double checked my receiver app settings.
File copy the receiver.hml file provided in the sample sender app. Place it in a public dropbox folder. copy that public link to my clipboard.
Go back to where you registered your Chromecast device(s). https://cast.google.com/publish -Add An Application. I called mine : ReceiverSimple
Edit the app you just created, and for the URL field: paste in that public link. For you, set the platform to Chrome. It did not seem to matter whether or not i included the package name, so try leaving it blank.
Save It. Now COPY to clipboard the ApplicationID for the receiver you just created.
Open the provided sender app source code, and find where it's using APP_ID (hopefully R.Strings or equivalent in chrome ) Paste that App ID in. That will tell your client to use your receiver app, (and therefore, load that receiver.html file into the chrome cast screen).
also try a chrome cast reboot as another means of sanity checking.
I think you're close.
I'm wondering, is it even possible to treat the request for the Xul Browser component to open a new window? I tried changing the window.open function, but looks like it's never called.
All links that open in a new window are not opening in my application.
I found this page on the subject, but the provided solution is showing no different behavior.
Any hint on this?
(by the way, I'm developing a stand alone application, not a Firefox's extension)
I'm assuming you are in a XULRunner application, and that you are trying to load a chrome URL from a non-chrome source in a browser (e.g. HTTP or local file). While enabling UniversalXPConnect and UniversalBrowserWrite can be helpful, they are also a security risk (since any arbitrary script on the web could use them), so they tend to be disabled in browsers (for example, running that line in Firebug will give you an exception):
>>> netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect UniversalBrowserWrite");
Error: A script from "http://stackoverflow.com" was denied UniversalXPConnect UniversalBrowserWrite privileges.
How about you try using codebase security principals and see if that makes a difference? (http://www.mozilla.org/projects/security/components/signed-scripts.html#codebase). For me in Firebug it does allow me to get the additional permissions after I OK it with a big, nasty looking dialog), but still doesn't allow me to open a Chrome URL with window.open. The next step is probably to try changing your conf file to use contentaccessible so that the relevant parts of your content are accessible (see https://developer.mozilla.org/en/Chrome_Registration#contentaccessible).
To avoid the nasty message when elevating permissions, you could try setting permissions for the right files automatically as described at http://forums.mozillazine.org/viewtopic.php?f=38&t=1769555.
Also, make sure you check the browser type (https://developer.mozilla.org/en/XUL/Attribute/browser.type). If the browser type is not chrome, then it might be worth trying making it chrome and seeing if that makes a difference.
If any of my assumptions are wrong get back to me and I will try something else.
does normal js not work?
window.open(url,windowname,flags);
There are two ways that I know of.
The first is to set the browser.chromeURL preference to a chrome URL that contains a <browser type="content-primary">. The page that the content window tried to open will load into the given browser.
The second is to set the property window.browserDOMWindow with an object that you define to implement the nsIBrowserDOMWindow interface. This allows you to divert the open call into a tab, if you are using a tabbed interface. Note: the tabbed browsing preferences must be set to allow windows to be diverted into tabs, otherwise XULrunner will fall back on browser.chromeURL.