problem about NPAPI plugin ...my browser was blocked ! - plugins

Tools I use :
Browser: firefox 3.6.17 and Google Chrome
Interface:NPAPI
My question:
I want to callback a Javascript function from my NPAPI plugin by calling NPN_invokeDefault after finish to execute "Exec_func" , but it takes secends to execute "Exec_func" ( the browser wait for its return!). for this , I have to create a child thread to execute it ,otherwise the browser will be blocked !
if I do this , the browser firefox still be blocked like doing nothing , and the browser google chrome will tell me : return error after execute NPN_invokeDefault .
Regards
addition:
how do i async callback javascript funcs from plugins ,meantime the browser won't be blocked
thanks
Regards

The NPAPI documentation is very clear about the fact that you cannot call NPN_* functions from any thread but the main thread.

Related

How to get the response body during a Selenium UI test run

Scenario: Grab the authToken after a login.
Pseudo code | Steps :
Login via UI ( selenium )
grab the authToken via Rest.
Note :
I know how to do this completely via RESTassured or Postman but what would be a good approach to handle this during an automated UI test run.
It's easy to do it manually via Chrome Dev tools but using Java - it's a little bit challenging.
Any help would be nice.
If you have the auth token in the cookie then you can use the below.
# update auth_token below with the correct cookie name
authToken = driver.get_cookie('auth_token')['value']
You can fetch out the token value from the client side. It can be in cookies, local storage or the session storage
Check these value in browser. Open developer tool -- Go to application tab and on the left menu u can find these values for each website
or
Try following js command in the browser console
window.document.cookie
window.localStorage
window.sessionStorage
if u can find your token via any of the above js command , use can use them in selenium.

Wicket 6 PageParameters empty on Chrome and Opera

I have migrated my web application from Wicket 1.4 up to 6.21.
Everything is working fine on Firefox, but on other browsers (tested on Chrome and Opera) on some pages PageParameters are empty.
I checked POST requests and looks the same on each of mentioned browsers. Addresses on each browser are also the same and containing param I want to use.
My constructor:
public MyPage(PageParameters params) {
super(params);
id = params.get(ID_PARAM).toInteger();
// do stuff;
}
causes (of course):
java.lang.NumberFormatException: null
My knowledge about Wicket is rather limited, but app on Firefox is really working fine, so I want to run it on Chrome also.
Any answers or even advice what should I check are very welcome.
Of course I can provide some additional details and code.
EDIT:
Here is screenshot of POST on Chrome (on server PageParameters are empty):
While debugging I encounter really strange behavior. On MyPage there is AcceptButton which redirects to AnotherPage.
Using Firefox clicking AcceptButton results entering AcceptButton#onSubmit method, which is calling setResponsePage(AnotherPage, params).
Using Chrome clicking AcceptButton results entering MyPage() constructor, without entering AcceptButton#onSubmit nor AcceptButton#onError, so somehow it tries reload MyPage.
I have no idea why Firefox works but in the attached image we can see that this is an Ajax request, so it should not go to MyPage constructor at all.
The Ajax request is targeted against AcceptButton (an AjaxButton, I guess) so the post parameters could be read in AcceptButton#onSubmit(AjaxRequestTarget, Form) with getRequest().getPostParameters().
Maybe you redirect to MyPage with setResponsePage() or something like this but the Ajax request parameter(s) will not be automatically forwarded to the page's PageParameters in this case.

click_no_wait and then execute_script

I'm using the page object gem with a page that contains a link.
When the link is clicked, the browser navigates to a new page, and the HTML renders as expected.
However, my script is always returning a Timeout::Error: Timeout::Error. After looking at the browser network activity, I noticed a pattern with a long running get that never completes.
If I run the script and then go to the console and issue the command
$.connection.hub.stop(), the script will not time out.
Is there a way to perform a click_no_wait or to click and then execute a script via the use of page_object_gem ?
Here is my page-object attempt, but it is resulting in a timeout still.
class MyThing
include PageObject
include PageObject::PageFactory
link(:show_details, :id => 'detailLink')
def click_show_details_no_wait
begin
show_details_element.click
rescue Exception => e
execute_script('$.connection.hub.stop();')
end
end
end
It is hard to suggest without your page. My first idea is to try to do
show_details_element.fire_event('click')
instead of a usual click.
The second idea is take a look at
Stop loading page watir-webdriver
Is there have method to stop page loading in watir-webdriver
how to click on browser “stop loading this page” using ruby watir?
Good luck.

Login to Chrome Authentication window using AutoIT

I tried login to firefox authentication window by following code :
WinWaitActive("Authentication Required","","120")
If WinExists("Authentication Required") Then
Send("username{TAB}")
Send("password{Enter}")
EndIf
But the same dint worked for chrome even though it has the same title as firefox.
Any idea?
#Milos #Samoth thanks for spending to solve my query.
Using Autoit windows info tool, i could not identify the windows tile in chrome thats not a case in FF or IE. Instead of that "Autentication Required" identified as visible text.
So modifying the code to
WinWaitActive("","Authentication Required","120")
If WinExists("","Authentication Required") Then
Send("username{TAB}")
Send("password{Enter}")
EndIf
did the trick for Chrome browser.
If somebody is interested in Selenium for Chrome using Visual Studio and NUnit Framework, you can follow these steps:
Install AutoItX.Dotnet NuGet package for your testing project
Write the following code:
IWebDriver _driver = new ChromeDriver();
_driver.Navigate().GoToUrl(#"your_url");
AutoItX.WinActivate("", "Authentication required");
AutoItX.Send(#"domain_user_name{TAB}password{ENTER}");
and you are logged in your web application.
A lot of credit for this goes to #CristiG for this.
You will need the AutoItX.Dotnet NuGet package
Use this code to login, just ignore the commented out lines unless you want to see if you can get it to work without the Sleep() for robustness.
new Thread(() =>
{
Thread.Sleep(500);
// AutoItX.WinWait("", "Authentication required");//fails
AutoItX.WinActivate("", "Authentication required");
// AutoItX.WinWaitActive("", "Authentication required");//fails
AutoItX.Send(#"username{TAB}pass{ENTER}");
}).Start();
driver.Url = "http://yourpage.com";
Cristi's method didn't work for me, because the call to GoToUrl() blocks when the login dialog box pops up.
But that can be fixed simply by starting a thread to do the login before calling GoToUrl().
It would seem you could use either WinWait() or WinWaitActive() to eliminate the need for the Thread.Sleep(), but I couldn't get either to work, so I was left with the ugly Thread.Sleep(), but this approach
works for me.

FB.getLoginStatus not calling its callback

The title really says it all. Under some (undetermined) conditions FB.getLoginStatus() just stops working and won't invoke the callback I gave it. The only interesting clues I've found are
FB.Auth._loadState is stuck on "loading" -- whatever is supposed to make it click over to "loaded" isn't happening
slight delays like putting in alert() calls tend to make it start working
Any hints at all about even how to investigate this welcome.
This usually happens for me when I am running the page under a different domain from what has been registered in Facebook. Typically this is when I am developing locally.
If you are running locally, you'll have to set up a local web server and then modify your hosts file to point the the registered domain to 127.0.0.1 in order to test on your local machine. Don forget to remove that line from the hosts file when you want to test it on the server.
According to:
https://developers.facebook.com/bugs/240058389381072
You cannot put your application under sandbox mode, or else it won't work. Go into your app settings, advanced, and switch it. This stumped me for a couple hours until I happened upon the bug report.
I had similar problem with FB API. It turned out, that my Facebook App was misconfigured. Please make sure that this is not the case for you. My problem was that my "Site URL" param in FB application was pointing to https, but I was using http protocol for development. Any call against FB api after FB.init was not calling my callback functions. So the first thing to do should be to double check App config.
Now, if some reason you depend on FB api but you wish to have a fallback option in case it;s inoperative - workaround with timer should be ok for you. Just set up a timer and disable it if FB Api gives you proper response. If not - fallback to some custom function which will perform some additional logic.
function callFbApi() {
var timeoutHandler = setTimeout(function() { requestFailed(); }, 1000);
function requestFailed() {
// When this happens, it means that FB API was unresponsive
doSomeFallbackWork();
alert('hey, FB API does not work!');
}
FB.getLoginStatus(function(response) {
clearTimeout(timeoutHandler); // This will clear the timeout in case of proper FB call
doSomeUsualWorkAfterFbReplies();
return false;
}, true);
}
If your application is in sandbox mode, Facebook acts as if your application is invisible to anyone who is not listed as an application developer. If you're not logged in, then it would stand to reason that your app is now invisible.
The callback will only fire if you're initializing with a visible application. Otherwise the following response is returned:
<span>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. </span>
For more info please see my comment on this bug ticket:
https://developers.facebook.com/bugs/240058389381072
Maybe you are using the asynchronous call. The same thing happened when I called FB.init with window.fbAsyncInit. All I did was delay the FB.getLoginStatus with a setTimeout function
window.setTimeout(checkLogStatus, 1000);
function checkLogStatus(){
alert("check");
// fetch the status on load
FB.getLoginStatus(handleSessionResponse);
}
It seemed to work after that
On the new version of the Developer app, you have to make sure to have put the correct URL you are using to access the application in the Website field under the
Select how your app integrates with Facebook
section.
Make sure the protocol is HTTPS and not HTTP.
I had a similar problem. The site worked every time when I was opening the browser, but fails when I tried to reload.
The cause was the missing "www" on the site name on Facebook configurations. Note that putting "www" (like www.yoursite.com) works on both situations (yoursite.com or www.yoursite.com).
As others have posted, you must be accessing your site at the same URL that facebook expects. For example if facebook has a callback "example.com" but you're browser has "www.example.com", that can cause this problem.
In addition, if third-party cookies are not allowed by your browser, you may also see this problem. Or you may see the callback erroneously reporting the user is not connected.
Just posting a situation I had were calling FB.getLoginStatus got absolutely no response.
My application is designed to run in a tab, and I only entered the Page Tab URLs on the app admin page, and not the App On Facebook (i.e. Canvas) URLs. The tab loads perfectly, but any calls to the FB JS SDK provoke no response.
In Facebook App Settings, go to Client OAuth Settings, look at Valid OAuth redirect URIs
Make sure you have listed all URIs which are the domains from which Facebook SDK is being invoked. For example:
I develop at localhost:5000 and deploy to Heroku. Notice the format: http://domain.name/