Create a plugin for WebKit browsers [duplicate] - java

I'm curious as to the procedure for writing browser plugins for browsers like Chrome, Safari, and Opera. I'm thinking specifically of Windows here and would prefer working with C++.
Are there any tools or tutorials that detail the process?
Note: I am not referring to extensions or 'addons'. I'm referring to a plugin similar to how Flash and Adobe Reader have plugins to handle specific content-types.

As others point out, plugins for those browser are written using the NPAPI.
Note: Both Firefox and Chrome will default most plugins to click-to-play soon, with Chrome planning to phase out NPAPI entirely. NPAPI for new projects is discouraged at this point.
Resources for getting started with NPAPI:
MDC plugin section
three part NPAPI tutorial
memory management in NPAPI
npsimple - the "Hello World" of NPAPI plugins
npapi-sdk - the source for the canonical NPAPI headers
Mozillas test plugin - good for looking up specific NPAPI use cases
The NPAPI itself is however relatively low-level, but there are tools and frameworks that can help you with it:
FireBreath - cross-browser, cross-platform frame-work for plugins
Nixysa - generate glue-code for NPAPI plugins
JUCE - application framework also providing support for plugins
QtBrowserPlugin - Qt based browser plugin framework

I investigated some frameworks listed by Georg, here is what I get:
FireBreath. I think it is almost the best one available. You can create a cross platform browser plugin with FireBreath in a few days. I did find some cons: It does not support utf-8 characters on Windows. For example: if there are Chinese characters in a file name, you cannot read the content of that file. I believe that boost/locale can resolve this issue. But FireBreath does not contain boost/locale. Yes you can use external boost, but I spent several days configuring and tweaking and still cannot get it compiling on Windows. The author uses cmake to orgnize code and sub-projects. And he created a lot of bat or shell scripts and cmake macros, it is very hard to understand and configure. In short, if you want something that FireBreath currently does not provide, you will have a bad luck, it is very hard to add new features.
Nixysa. I don't think that it is being actively developed. Documentation is poor. And from the comments of the wiki page: https://code.google.com/p/nixysa/wiki/HelloWorldWalkThru We can know that users could not get help at all and were having trouble get it running on Windows
JUCE. It is not specially for creating browser plugins. It does NOT support Linux. The author thinks that NPAPI is going to die so he has no plan to support Linux or add new features.
QtBrowserPlugin. You can not find it in documentation later than QT 4.5. In another word, it is not maintained(and removed from Qt 5.0)
I will update this answer once I find more.
Update: Chrome dropped NPAPI support. I think in the future it becomes harder and harder to write plugins in C++ because lacks of support from browsers.

Browsers like Netscape-based browsers, Chrome, Safari and Opera uses NPAPI plugin system, you can learn how to write NPAPI plugins in https://developer.mozilla.org/en/Plugins and http://code.google.com/chrome/extensions/npapi.html

If you know Qt then they have got some classes that makes it easier to implement browser plug-ins

Related

What are some alternatives to Selenium?

What are some web UI automation frameworks available out there?
I know about this question, but it was asked 3 years ago and things have changed a lot since then. I just wanted to find out if the answers to that question are still relevant or there have been newer and better tools developed since.
I'm asking this again because after doing some googling I've stumbled upon tools such as Geb and Capybara that were not mentioned as an answer in that question.
there have been newer and better tools developed since.
Take a look at the TestCafe testing framework. It runs functional tests in any modern browser and any device. No WebDriver required.
TestCafe is a pure node.js solution.
It can be easily installed (npm install -g testcafe is enough).
Works without plugins for browsers and additional configuration.
Write tests in ES6 and ES7 JS syntax.
Has smart waiting system, so runs async tests fast without extra waiting.
Can be easily integrated to your CI system.
Support for running tests on remote machines, devices, and cloud.
Free and open source.
You can use WATIR with Cucumber. Infact facebook uses watir for its UI automation.
I would definitely stick with Selenium, TestNG (and Selenium Grid for industrialisation).
If you want something at a slightly lower layer, you can also look at HtmlUnit.
IBM Rational Functional Tester (IE and older firefox builds) or QA Wizard.
RFT runs on Java/Eclipse.
https://stackoverflow.com/a/13024991/423955
Sahi (http://sahi.co.in/) should be the best alternative for selenium. One can use java or javascript for the sahi scripts, php and ruby driver is also available (no personal experience with Ruby or php). Very effective with cross browser as well as cross-platform.
Some of the lovable features are: No explicit wait required. For element identification _near, _under, _in etc ApI's are very useful. Logging/Report, feature is inbuilt with Sahi. No Complex configuration required to run the Sahi scripts

Javascript/CSS/HTML/Java IDE?

So here we go. I want to choose between Aptana, Eclipse, and Netbeans. I want a sort of all inclusive program as I try out these different languages to see what I want to try out. I have VS for my C/C++. So do any of these support HTML, CSS, Javascript, and Java? I think it's netbeans but I'm not sure.
Also, what is the best paid app for Javascript? Is dreamweaver any good?
Aptana, Eclipse, and Netbeans all support HTML, CSS, JavaScript and Java.
Aptana is actually Eclipse under the covers with what looks like better support for web applications.
I have used Eclipse extensively and found that it was sufficient for my Java web development work.
Recently I have switched to using IntelliJ IDEA after using their JavaScript IDE - Webstorm. IntelliJ IDEA is a full-featured IDE with great support for various languages and frameworks. Webstorm (as far as I can tell) is a cut-down version of IntelliJ IDEA specifically focused on JavaScript development.
The great thing about IntelliJ IDEA and Webstorm is their support for mixed languages. That is, if you have HTML, CSS, and Javascript all in one file, it understands it all and highlights, and formats, the code for you properly. Another great feature are the code inspections which analyse your code for errors and common mistakes - this is a great feature.
Both IntelliJ IDEA and Webstorm are paid applications, but you can try them out for free for 30 days.
I would highly recommend trying out IntelliJ IDEA and/or Webstorm.
Eclipse is a develpoers best friend. Every language leave for .NET, but it's MEANT for Java, and the others. And NEVER buy an app to develop, it becomes a crutch.
And Eclipse has a million and a half plug-ins that can become super useful... just found this LESS CSS compiler that runs on file save... epic!
Depends on what you're doing but every place I've worked for prefers Eclipse over anything else, may just be industry standard but I get along with Eclipse very well. One thing that stands out it's modularity and the ability to find a plugin for any specific technology. I have used Netbeans in the past and it's not bad - perhaps the biggest advantage, at least when I was using it, was the built-in GUI builder specific to Swing applications but I suppose it's a matter of preference in the end. I believe both have support for the technologies that you mentioned although I haven't encountered Aptana before.
Aptana is actually Eclipse, bundled directly with highlighters for CSS, HTML, JS and adds additional very handy functionality. But you just as well could use eclipse and download all the plugins via the plugin manager and you'd have the experience of pornific-java developement, as well as porntastic javascript/html/css possibilities.
I'd recommend Aptana, unless you really need Java, then I'd do the Eclipse+Plugins attempt.
There are Eclipse builds for everything and is widely used. Netbeans is more for (you guessed it) web development, but I find a lot of people find it easier to use. Eclipse confuses people when they start using it. They both do HTML, JavaScript and CSS pretty well.

Portable web browser embedded in java app?

Question: embed a portable web browser without cache into a java app? Using Java SE.
Can this be done? Are there any JNI supports for e.g. Chrome or Firefox?
Maybe Qt? QtJambi would allow interfacing with the Webbrowser? From what I understand QtJambi is now maintained by the community and LPGL, is QtWebbrowser embeddable for this purpose in the same licence?
Examining the available documentation and over the past few days this is what has emerged:
The open source browsers are Webkit (which is used for e.g. Safari), and the Mozilla flavoured Firefox. There is also Chromium which is the open source version of the Google flavoured Chrome which uses a lesser javascript engine (squirrel as opposed to v8) and does not have the multi-separate-thread modularisation of Google Chrome.
Additional information on Firefox: Mozilla Firefox is based on an application called xulrunner which uses xml and javascript to provide the additional functionality of firefox (other than the 'not so basic' browser - such things as the html parser, css renderer and javascript parser). Xulrunner is the implementation of the browser.
Firefox implements its own private xulrunner, however additionally there is xulrunner as a standalone install.
Xulrunner can be used to create standalone applications, that are based on a web-browser, and has support for javascript. Xulrunner is also used to create the plugins for firefox providing additional functionality.
In order to connect the front end to something a bit more sustained and powerful than javascript (which has improved in leaps and bounds in recent years), but is still not the strongest sustained engine, there is a C-library called xpcom.
Xulrunner uses xpcom (written in C) to expose the javascript variables and parse the dom, and link javascript variables, and do other 'browsery' things like read headers etc. More on Xulrunner and xpcom in a moment.
If you want a browser that is recent and functional (html 4 or 5, good support for css2 at least, and some css3, and solid rendering of javascript), your best bet other than compiling and embedding one of these open source browsers is to use SWT.
SWT is a gui interface, similar to swing, except that it implements a webbrowser type interface, and can be used to implement a browser. SWT also has some developed interfaces to interact both with the dom and the like. SWT was developed by IBM and is actively maintained.
What SWT does is implement the OS system browser, and has support for every major os. On the upside, this means that there is no need to embed your own browser, on the downside you are stuck with whatever browser / parsers exist on the operating systems, at whichever version. The default behaviour on a windows os for SWT is to use Internet Explorer.
It is also possible to implement non-os linked browsers like firefox by installing xulrunner, but this is an additional 20mb (not extensive but something to note), as the more recent versions of firefox are not recognised.
It is a requirement to have javaxpcom support and xulrunner to implement a firefox style browser in SWT. The easiest way to go about getting the last version supported by Firefox (xulrunner 1.9.) for javaxpcom is to download an application called prism. Prism uses xulrunner as its base to create browsers that are standalone to specific urls. There is a known hacked xulrunner 1.9. which has some issues - see wikipedia for information on this, if you aim to download xulrunner 1.9.* compiled already from source.
Xulrunner is developed alongside each and every new edition of the Firefox browser. Until v 1.9.* (firefox 3.* if I am not mistaken), there was additional support for a function called javaxpcom which was an interface written to link the c library Xpcom's functions to java.
Firefox's initial announcement of how easy and simple it was to embed and style your own flavour of xulrunner, and that it was easy to port to many different languages (support for C, initially support for Java, Python amongst others), but obviously there is some overhead to accessing and adding libraries.
Xulrunner is being promoted as a potential software solution to compete in the same playing field as java, but suffers the same limitations of javascript / html applications. Within those parameters it functions.
Since version 2 of xulrunner, support for javaxpcom has withered, as there is no active maintainer of that code. It is open source solution so presumably interest from someone with requisite skills might pick that up. Xulrunner is now recently in version 6 at the time of writing this answer. Xpcom however is still going strong. Presumably there was insufficient interest / activity in the community, amongst other potential issues.
Since javaxpcom has been reported to have broken, and requires someone to maintain an interest in the code; that work would have to come from someone who has a vested understanding of Xulrunners xpcom, or at least a collaboration from someone who has an understanding of changes made in xpcom. Comments from what I have read suggest that documentation on xulrunner may not be a detailed as it could be, nor on javaxpcom, but I am not in a position to evaluate these comments.
I had hoped that the basic core functionality could simply have been maintained, keeping the hard work involved in recent browser improvements in functionality 'embeddable'. Firefox's amendments have resulted in extensions breaking in newer versions, a function of keeping up with the times.
A non-open source solution that embeds a web-browser and the like is called webrenderer.com. It is maintained, but there is a price tag attached, which is not insignificant.
Another possible route to implement a web-browser in a java application is to go the route of a cross platform development platform called Qt. QtJambi is a LPGL licensed (previously commercial) webbrowser that has extensive documentation and support for Java implementation. There is obviously learning curve attached to using any new platform. Reasons for the move from commercial to LPGL? Presumably viability and commercial demand for java supported browsers has .... waned? A function of the times we live in no doubt.
GWT is the java / webbrowser google solution. GWT works by allowing developers to write java solutions, and then ports and converts this solution into a stable javascript that can be obfuscated. However GWT is not suited to developing a desktop type application, in the sense that it requires a 'server' implementation for the backend. In this sense it is most suited or similar to a PHP or ASP style client / server solution.
Whilst it is not impossible to write GWT as a desktop application, presumably you would have to implement Apache Derby, or Jetty or similar as an in-house server to do all the to-ing and fro-ing. Its not neat, elegant or specifically designed for this, but madder solutions have been tried. There have been php style desktop applications.
For a number of political and financially motivated reasons it appears that support for porting / embedding java and open source browsers is not on the up and up, a trend which began with apple's lack of interest in supporting java applications. Mind you, the browsers are open source and presumably with enough time and energy, javaxpcom etc. could be sustained, but who is going to do this for free, I do not know.
Java promised a java browser implementation but this was not released with the Java 7, and requires like most other things, an amount of work. Perhaps in 8? It is unclear even there if it will be ready by then, I can't quite work out if its currently on the roadmap or not, and doesn't appear to be their highest priority include.
SWT requires some additional libraries and installation to work on various platforms.
Some other open source solutions which do at least in part appear to work, but the maintenance, support and current interest in appears mixed to none, include JRex, MozSwing. Rhino is a javascript engine, flying saucer an html4 renderer.
If you are talking about Java SE based application I would highly recommend swt 'Browser' component. I have used it myself within Eclipse RCP based app and it works like a charm (flash, javascript support)

Which flavor of eclipse to download in order to start developing with GWT?

I am new to the world of Java and web programming. Never wrote a single line of javascript and my knowledge of HTML is pretty basic. Although, I am very experienced with .NET, so I guess transition to Java should not be a revolution.
Anyway, I wish to learn GWT and for that I want to work on Eclipse (I have Mac at home, so no Visual Studio).
Now, there are a dozen different download flavors of Eclipse, so my question is - which one best suits my needs?
Thanks.
P.S.
This is probably not a factor in the decision, but I will need Visual Studio keyboard bindings. I want to believe that no matter which flavor I install, I will be able to change the keyboard bindings later.
You should be fine with any version of Eclipse. Eclipse is extremely modular so it's only really a case of ensuring you have the correct plugins installed.
I'd recommend:
Start with the Eclipse IDE for Java Developers as a base install. This has everything you need for Java (i.e. the Java Development Tools, stndard editor features, source code control etc.)
Then install the GWT plugin for Eclipse
After that you should be good to go. If you find you need more plugins later, you can easily add them.
I also know both .NET and Java, and you should not have have much difficulty making the transition - it's really just a case of learning a few slightly different conventions, APIs and ways of doing things.
With regards to the keyboard bindings, I've never really changed from the default settings myself but they are completely customizable so I'm sure you can get it set up how you want. You might want to look at the answers to this question, which give you a few options (apparently you can download the full set of bindings, or install the C++ plugin which includes them).
I would probably start by installing Eclipse for Java EE developers and then the GWT plugin. It will cause less dependencies to be installed and you will get some things installed that you will probably want to start using later. But regardless of whether you are using that or the Java developer-version you should not have any major problems.

Best Blackberry Dev environment

What development environments do most BB devs use out there? I haven't programmed much Java in 6-7 years and typically used NetBeans or JCreator for projects as I found Eclipse cumbersome. RIM has the plugin for Eclipse, but I've also read some posts where people are using whatever editor they want and then using ANT for builds and testing.
I'm coming from .NET so obviously I'm a heavy VS.NET user.
Your supported options are JDE (simply not very capable compared to any modern IDE), and Eclipse. For widget development, the VIsual Studio plugin supports VS 2005 and 2008 (I don't think 2010 is yet, but I expect it won't be far behind.)
I've gone through great pains trying to stick with Netbeans (Eclipse makes me itch), but eventually had to give up and switch to Eclipse. The support simply isn't there; I was able to get the basic debugging to work with Netbeans, but that was just about it. Simple things like "break on uncaught exception"; or localization handling (if using string resources) were either not possible, or very inefficient.
The JDE is adequate for debugging, if only barely. However in my experience (especially in the very latest versions) there's no difference at all between the JDE and Eclipse debugging features.
The other option you have is to use the IDE of your choice; and ant-based build scripts. That would let you use . You will still have some pain points (mostly localization handling), but it would do the job. The Blackberry Ant Tools project can be found here: http://bb-ant-tools.sourceforge.net/docs. In this case you would still want to use JDE/Eclipse for ease of debugging, but would be able to do most of your development in the IDE of your choice.
I would recommend using both RIM tools. Eclipse plugin is good for development and now even supports hot-swap debugging on the Simulator.
But if you need on device debugging and logging - for me, only JDE worked correctly, so I keep both these tools in my toolbelt :)
If you want to try the ANT route, it's possible, for example look at Wordpress BB application, it shows a good way of working with BB project and ANT. IntelliJ handles it pretty well.
There are a number of specific free development environments provided by RIM, and which you can download, including an Eclipse plugin.

Categories

Resources