Using form submit from script on extension page - safari

I'm developing an extension for Chrome, Firefox and Safari and I'm adding a feature that uses a form.submit style post to initiate a search on another web site.
I have the code working in Chrome using the method described in this post:
Chrome Extension Development - POST to new tab
However, it doesn't work in the Safari extension. There are two problems. The first is that the sendMessage to the new tab never gets to the post script. I found a solution to that: in Safari it doesn't treat a script loaded by an extension web page as a content script. So I have to use runtime.sendMessage rather than tabs.sendMessage.
The second problem is where I am stuck. The post script submits the form but there appears to be an error on the server side and I am unable to see what it is.
In the Safari Web Inspector the "Preserve log" doesn't keep the log when this error occurs. The server loads a new page (with blank search fields) and I can't see any info on the request header sent with the post or the response since the Web Inspector logs are cleared.
I suspect it may be a security issue since Safari tends to be more strict. Any ideas on any ways around this?

Related

Getting error using Firebase popup authentication in Word add-in

I was already using Firebase for authentication for other (related) projects and would like to stick with it.
Using Firebase with a Word add-in seems challenging. On Windows you're stuck with IE11 and on Mac (crucial for me) the browser used to load a taskpane is webkit, not the default browser.
I can get authentication on Windows to work just fine if I use signInWithRedirect (Google and Facebook).
But this won't work on Mac. Using signInWithRedirect opens a new tab in the default browser, which doesn't share cookies/data with the webkit browser the add-in actually uses.
When I switch to signInWithPopup, I get:
There is no application set to open the URL about:invalid%23zClosurez.
On Windows I get a popup IE11 window, for a split second, and it contains about:invalid%23zClosurez for a URL.
I have appdomains called out in my add-in XML manifest:
<AppDomains>
<AppDomain>https://writeitwithme-a114a.firebaseapp.com</AppDomain>
<AppDomain>https://www.firebaseapp.com</AppDomain>
<AppDomain>https://www.googleapis.com</AppDomain>
<AppDomain>https://www.facebook.com</AppDomain>
</AppDomains>
Any help appreciated. Worst case I drop to using manual registration, via Firebase, for Mac, but seems unfortunate to have to give up.
Just documenting for anyone finding this later.
I couldn't figure out how to use Firebase social login when creating an add-in for Mac. Every authentication window opened in the default browser, not the webkit engine used by Word on Mac. Sticking with manual login worked.
IE11 is always finicky when using localhost. I test elsewhere, then push files live and then try IE11 and social + manual login (via popup) works just fine.
I found the following resources from Microsoft docs that made this easier for me:
https://learn.microsoft.com/en-us/office/dev/add-ins/develop/dialog-api-in-office-add-ins
Basically you need to make a call to open up a dialogue box:
Office
.context
.UI
.displayDialogAsync(
'https://myDomain/myDialog.html',
{height: 30, width: 20, displayInIframe: true}
);
Then you can make your own page that does a login flow and passes a message (likely a credential of some kind) back to your plugin via the messageParent method:
Office.context.ui.messageParent(googleProfile);
From there you can do the following to sign in with the credential provided in your add-in:
firebase.auth().signInWithCredential(credential)
Also, be very careful with how you construct the URL of the dialogue box. I lost hours not knowing that the _host_Info param from the origin URL would mess stuff up (I was constructing my new URL from the origin URL). Figured it out in this github issue: https://github.com/OfficeDev/office-js/issues/378

InternetExplorerDriver not opening site, but user can open it

I'm working in a highly secured environment. I can only use IE11 by company's policy. I'm trying to implement test automation on my project.
I'm using Selenium and IEDriver.
Currently I'm trying to implement basic scenario by just opening application page.
When I'm trying to do it via IEDriver, the page is not getting opened and the message "This page cannot be displayed" is shown.
But when I open the page manually by just typing in the url to the address bar everything works fine.
I guess it has something to do with the cookies that are coming with the request I'm making manually. Seems like those cookies contain some signature.
Can someone advise me how can I track the problem to resolve it?
Thanks.
Be sure top follow the required configuration section on this site: https://github.com/SeleniumHQ/selenium/wiki/InternetExplorerDriver
I had some issues with IE acting the same way until following this setup.
So the issue was fixed by setting proxy.
Seems like there was a change in security rules recently.

Can I use an IFrame to navigate to an external page in a Windows 8 Metro application?

When I currently try I get the following error, even after adding google as a content URI
APPHOST9613: The App Host was unable to navigate to http://www.google.com/ due to the following error: FORBIDFRAMING.
Response from MSFT:
http://social.msdn.microsoft.com/Forums/en-US/winappswithhtml5/thread/a1cba639-3251-4df8-abd3-b6f6a95ba4ae
You can use Iframe,but you won't get full controll of their JS files,you may have to face some breaking point in such sites, and some sites like google blocking this facility.
Try this,
1. Make your default browser as IE10 which will provide you an App look for IE.
2. trigger an event
function openYourLink() {
var url = new Windows.Foundation.Uri("http://www.google.com")
Windows.System.Launcher.launchUriAsync(url);
}
You can use iframe to navigate to other pages.
<iframe src="http://www.apple.com" />
will do the trick.
However, not every website allows you to put their page in an iframe or they maybe using the top window layer so that their page doesn't support running in an iframe.
In addition, if you are running your code Visual Studio 11 Express, it may throw javascript exceptions in the web page in the iframe. You can "continue" it. This exception will not be visible when you are running a deployed version of your application (running from start menu).
On further investigation the answer seem to be that yes you can for most sites, but some sites (such as google) seem to fail when embedding with an iframe.

Google Chrome 16 issues with ASP.NET forms authentication cookie

I have a problem with Google Chrome 16 on one of the sites I'm supporting that I can't fix couple a days now.
The site is using forms authentication. There is a hyperlink that when clicked is calling a web handler, that is supposed to go fetch a PDF file. Everything is working great in all browsers except in Google Chrome.
When I click that link in Chrome it gives me 401 - Unauthorized: Access is denied due to invalid credentials.. I've checked the request headers and the only difference I can see is that the authentication cookie is not present in the request made by Chrome 16. The strange thing is that everything is working great on the local machine, but once uploaded to the production server chrome is not sending that cookie.
I've implemented IReadOnlySessionState interface in the web handler, as suggested here and there in forums, but this didn't solve the issue.
Does any of you have an idea why chrome is acting like that?
To check your cookie acceptance:
Click the wrench icon (Top Right)
Click "Options"
Click "Under the Hood"
Click "Content Settings"
Make sure that "Block third-party cookies from being set" isn't
checked.
That was what fixed the issue on the site I was on. You can also see a special icon in the address bar on the right when it blocks a cookie.
For more precision there is a "Manage Exceptions" button under cookies in the Content Settings. You can use that to specifically allow the site in question.

Facebook Connect button not showing up in Safari/Chrome

My implementation of Facebook Connect (just a simple login button, fb:login-button) works perfectly on Firefox and IE.
But the same button is not showing up in Safari/Chrome (Webkit).
Here's what's ironic. In my debugging effort, I saved the page (that contains fb:login-button) up as a static page and then load it in Safari. And the button shows up, everything works!
The exact same page (with the exact same HTML source) rendered by my PHP has no way for bringing up the button.
I'm trying hard to support Webkit here but I'm close to giving up. Can anybody help?
I found one more way this can occur (the blame-myself-for-being-stupid way); it's probably not common, but in the event is saves anyone else the hassle, here it is:
This symptom can also be caused by various security tools blocking facebook resources.
In my case, I'd installed Facebook Disconnect ages ago in Chrome as a plugin and forgotten all about it being installed. I also had a second installation of Chrome that was seemingly identical (but did not have Facebook Disconnect). The first would properly load the fb:login-button, and the other would not; took me ages before I looked at the plugins, because Facebook Disconnect didn't have an icon and so its presence was pretty easy for me to miss.
Here's what you'll see if some sort of security plugin is preventing facebook resources from loading. Just look at the html that renders in the browser using developer tools.
In a normal chrome session you'll end up with something like this:
<fb:login-button><a class="fb_button fb_button_medium"><span class="fb_button_text">Your text here</span></a></fb:login-button>
But in the version with facebook's resources disabled you'll end up with this:
<fb:login-button>Your text here</fb:login-button>
Like I said, pretty obvious in retrospect.
Had the same problem but it was not related to anything like a plugin or malformed content. It seems if you enable country filtering on your facebook page it has an issue with the like button, this should be fairly obvious. Facebook gets your location from your profile and not your IP address.
Make sure to disable country locking if you plan on using the social plugins.
This can be due to having ClickToFlash installed. Either disable it, or check "Automatically load invisible Flash views" in the ClickToFlash settings.
What we found out is that Safari (and maybe some older versions of Chrome or other WebKIT browsers) have a problem with Facebook's code using the innerHTML JS function if your page arrives with an XHTML response header (application/xhtml+xml).
Using text/html solves the issue.
In case of JSF2, which we use, the implementing the fix was as simple as wrapping the FB button like this:
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:fb="http://www.facebook.com/2008/fbml"
xmlns:f="http://java.sun.com/jsf/core">
...
<f:view contentType="text/html">
<fb:login-button>Login using Facebook</fb:login-button>
</f:view>
Facebook bug report here:
http://bugs.developers.facebook.net/show_bug.cgi?id=5545
I had this problem with the Facebook button not showing at all and it took me forever to figure out what it was. Luckily after days of hair pulling I will now share the answer with everyone. In my situation I simply didn't have xfbml enabled. In my FB.init I had it set to false:
FB.init({
appId : 'app_id', // App ID
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : false, // parse XFBML
oauth : true // enable OAuth 2.0
});
I changed this to "true" (xfbml) and the login buttons works great now! :P Good luck!
This happened when I had the wrong domain in callback_url in config/facebooker.yml. Apparently it uses that to load the js files.
I had the same problem but I resolved it by making sure the URL in my app settings was exactly the same as the one for my site (i.e. it didn't work when I accessed my site without the www.).
I have tried every suggested solution here and it didn't work for me. But now I finally found the solution.
Facebook requires now a secured (https) for Canvas (Secure Canvas URL). The unsecured one will be deprecated soon.
Here is the main difference, Chrome doesn't like https connections with invalid certifications. On a localhost, it is very likely you have stunnel installed to allow https connection for the localhost. Firefox is ok with the self created SSL certificate and allows you to add an exception when trying to access that site. Chrome doesn't allow it out of the box.
When I load my app in Chrome the page is blank and I dont see any login button.
Click F12 and click the Netwrok tab in Chrome:
You see that the post request to your localhost is cancelled. DOUBLE Click on it.
Now you would see that chrome is blocking the localhost because of the certificate:
click on proceed anyway.
Now to back to your other tab and reload the page:
Chrome works now like Firefox and shows the login button.