Firefox sdk - access popup opened - firefox-addon-sdk

I'm currently working on a Firefox addon, and I was wondering if is there any way to access pop-up, in other words a window that was open using Javascript function .open().
If I access all tabs the popups are not there, if I access all windows the popups windows are not there.
//
var allWindows = window_utils.windows(null);
//
var tabs = require('sdk/tabs');
for (let tab of tabs)
console.log(tab.title);

If you know the popup's url you can use a PageMod to detect when it loads, its url, etc.

Related

Enable browser action for an event in Google chrome

I am writing a chrome extension for capturing the URL. This is the code for my js file.
chrome.tabs.getSelected(null, function(tab) {
myFunction(tab.url);
});
function myFunction(tablink) {
alert(tablink);
}
Now i can get the URL alert for the page by explicitly clicking on the browser action. I need it to popup the alert whenever i click on any tab in my browser.
Could you please let me know how to proceed with this?
PS: I am sure i have to use some kind of event listener.
chrome.tabs.getSelected is deprecated since Chrome 33. Use chrome.tabs.query instead if needed.
Base on your need to make popup the alert whenever you click on any tab in your browser. You can use chrome.tabs.onActivated.addListener.
The code I created is as below and it works with me. It popup the alert of current page's url whenever you click on any tab in your browser.
chrome.tabs.onActivated.addListener(function(activeInfo) {
//alert("popup");
chrome.tabs.get(activeInfo.tabId, function(tab){
alert(tab.url);
});
});
Also keep in mind to add "permissions": ["tabs"], in your manifest file since it requires access to the url. See here:https://developer.chrome.com/extensions/tabs

How to retrieve title and url of a openned com.google.gwt.user.client.Window

I opened a window with com.google.gwt.user.client.Window.open()
How to retrieve the title and URL of this new window after navigating in it ?
After openned a new window with "http://www.google.com" and searching "Stackoverflow" the title become "Stackoverflow - Google Search" and the URL change to "http://www.google.com/&q=stackoverflow"
I would like to retrieve these two informations in the parent window.
How do I do it with GWT ?
Example :
private void myMethod() {
Window.open("http://google.com", "Google")
// ... searching "Stackoverflow"
Button b1 = new Button(getTitleOfPopupWindow()); // Stackoverflow - Google Search
Button b2 = new Button(getUrlOfPopupWindow()); // http://www.google.com/&q=stackoverflow
}
Once you open a new window, it becomes a totally different window that your app cannot access - unless you have total control over its contents (i.e. it's on your domain). It would be a huge security and privacy hole if an app in one browser window/tab had access to the information in all the other windows/tabs.
You can let your users open an iFrame within your app and see where they navigate within that iFrame, if your users don't mind it.
If you have a total control over the new window, then you can insert a script in the child page to call the parent page using Window.opener. However, it looks like this is not your use case.

Open new browser windows in background using CoffeeScript

How can I open a new browser in the background?
I trying to use window.open, but the new windows always open with focus.
I tried to do:
popup = window.open(#pop_url, '', 'width=,height=,resizable=YES')
You would have to remove the focus from the new window using blur() and set the new focus to your parent window using focus():
popup = window.open(#pop_url, '', 'width=,height=,resizable=YES');
popup.blur();
window.focus();
But be aware since this method has been used in the past mainly for user unfriendly behavior or content this will be blocked my most popup blockers - even though this method is actually called popunder.

Sahi not able to recognize popup window

My application has several popup windows opening from javascript validations. Sahi is not recognizing those. If I manually add it like
_popup("windowTitle"),
It says no such window found. The windows are not javascript popups but normal html pages opening as popups.
the exact error message is:
_popup("Error Window")._click(_button("CERRAR"));
Window/Domain not found: popupNameFromStep=Error Window; derivedName=; windowName=; windowTitle=Happy Time; wasOpened=0
Here the title it is recognizing is actually the parent window title.
What does the controller records it as? If it is a popup or a different window, the controller will record it correctly.
You can use the API _selectWindow which will use to select popup.
// switch to popWin popup window
_selectWindow("popWin");
// perform actions on popWin
_assertEqual("Link Test", _getText(_link(0))); // no mention of popWin needed
var $href;
_set($href, _link(0).href); // no mention of popWin needed
...
// switch back to base window
_selectWindow();
// perform actions on base window
For more details you can visit this link: https://sahipro.com/docs/sahi-apis/popup-windows.html#_selectWindow

How to detect if a hyperlink has been clicked in a WebView in Metro?

Is there anyway i can get the hyperlink click in webview to my c# with Hyperlink value in Metro?. I am using WebView..NavigateToString() to generate the content?.
You can call InvokeScript with some of your own Javascript to set up a listener for when the user navigates away from your page. This would look something like the following in C#:
var navigationListenerString = #"
(function() {
function leavingPage() {
window.external.notify("LEAVING PAGE");
}
window.onbeforeunload = leavingPage;
})()";
webView.InvokeScript("eval", new string[] { navigationListenerString });
Then you can use ScriptNotify to listen for your particular message to determine that the page is unloading and the user is leaving. Unfortunately you cannot detect where a user is going. Also, if the hyperlink opens in a new window and the webview does not unload, you cannot detect that either.
Since WebView in windows 8 doesn't support Navigating() events like the Silverlight WebBrowser control, thus it is not possible to get hyperlink or cancel navigation.
But since you're using NavigateToString() method, you can write some manual javascript code and achieve same with the help of WebView.ScriptNotify() event.