How to pass a message from a webpage to a Safari extension (background/injected)? - safari-extension

It looks like that there is no way to pass a message from the script already in a webpage to a injected script or background page in a Safari extension.
Quite weird if true.

window.postMessage allows you to send a message to the extension scripts on the same page.

Related

Sense/Net download text file

When I try to download the text file in sensenet, the text file will open in browser but not downloaded, could you give some suggestions about how to set to download text file directly?
It's handled by the browser. If it can open a certain file type, then it will show it instead of downloading.
On server side you can force to download file types on your website if your http handler use disposition when set response stream:
response.AppendHeader("Content-Disposition", "attachment");
With sensenet you have to write your own http handler or modify ProcessRequest of SenseNetStaticFileHandler.cs.
MSDN is not too helpful on this topic, but you can find some information on this here.
On client side there is another solution, if you can change the html code of the link. With html5 <a> tag has got a download attribute that forces the linked file to download instead of navigate the browser to it. It works if the browser supports it. See HTML download Attribute.

Capture JSON response through Selenium

I'm testing a webpage using Selenium (either IDE or webdriver). The webpage has a "search" function, basically just a GET call with params. The javascript also output to console the JSON returned from the search call, i.e. something like console.log(data). And I'm able to inspect the response data in Firefox console.
My question is: is there anyway I can capture this data from Firefox console in Selenium (so that I can further inspect and doing asserts)? Writing a direct GET request (eg, from Python) does not work since the search url is protected through a login page.
Thanks.
AFAIK Selenium doesnt provide any in built API/method to play with console.
You can redirect console output file and read from file.
Link: How to redirect Firefox console output to file.
It was possible at one point using Firebug. Not sure if it still works.

Firebug - how do I see the request/response headers for "attachment" or other responses that trigger an open/save dialog?

Environment:
Firefox with Firebug and Jsonview addons installed and verified to work,
A web service that claims to send the response with "application/json" as the mime type; the service URL does NOT end in ".json".
Problem: Firefox puts up the open/save dialog instead of letting Jsonview to display the content.
Question: How do I see the response headers/content in Firebug for attachments or other responses that otherwise trigger an open/save dialog?
Related question: Is it possible to see headers/content in Firebug for responses that are targeted for popup windows?
Would like to avoid installing other plugins or network monitors if at all possible. Any help is greatly appreciated.
I've noticed that Firebug needs to be "refreshed" when you want it to display a request with Content-Disposition: attachment:
Try to switch to another Firefox tab, where Firebug is not activated, and then switch back to your current tab. Firebug will get refreshed and show also previously invisible request in its Net panel.
EDIT
Now it's known issue 7264

customizing apache tomcat authentication Required popup

i want to add a "register" link into the apache authentication popup.
i would also like to change the error message page that is called when you press cancel.
i looked into directory www/error where i found some files but it seem none of those files is the error page that is called.
how can i find the Authorization Required page that is called ?
so i can change it.
You can't - that's native browser behavior, not an Apache popup. Try different browsers and see how they do the popup differently.

Prevent built-in prompts in xul

I have an application that loads a web page in the browser and saves it to custom local folder (images, html, css). In the process the "src" attribute of images (in html) and "background-url" property (in css) need to be changed to reflect the locally saved files rather than the original ones. This generates extra web traffic as changing them forces the browser to download the files from modified locations (the browser does this by resolving the uri of the page with the value of element's "src" attribute - the same for "background-url" property ) and as a result, it generates lots of 404 Not Found requests.
I'm using nsIIOService interface to go offline before saving the page (the page is fully loaded and all network activity so far has been stopped) and then back online after the saving is complete. But then the browser displays an alert box "This document cannot be displayed while offline. To go online, uncheck Work Offline from the File menu." whenever I try to change the aforementioned attributes/properties.
Is there any way to prevent such message from appearing or to make the browser not validate the images because of modified "src" values?
I tried to use DOMWillOpenModalDialog on both the browser and the xul application window, but it seems it's of no use - the dialog still appears. The application is not an user application, so it's difficult when such "built-in" messages appear.
Use preventDefault to stop the modal dialog:
document.getElementById(‘content’).contentWindow.addEventListener(‘DOMWillOpenModalDialog’,function(e){ e.preventDefault(); }, true);
As an alternative, try using disablePrivilege, sandbox, redefining the prompt service, or overriding window.alert.