Skip to content

Commit

Permalink
0.0.3
Browse files Browse the repository at this point in the history
 - Enhanced code, docs etc.
 - Added JS_API interface
 - Updated GraalJS to latest release
 - Optimized JSContext
  • Loading branch information
Osiris-Team committed Sep 9, 2021
1 parent ef99976 commit 31c62ca
Show file tree
Hide file tree
Showing 19 changed files with 378 additions and 297 deletions.
59 changes: 37 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,65 +1,80 @@
# Headless-Browser

A headless browser written in Java.

```java
HBrowser hBrowser = new HBrowser();
HWindow hWindow = hBrowser.openNewWindow().load("https://wikipedia.org");
```

- This browser can load pages and execute JavaScript code.
- Contributions are needed for implementing [Web-APIs](https://developer.mozilla.org/en-US/docs/Web/API).
- Contributions are needed for implementing [Web-APIs](https://developer.mozilla.org/en-US/docs/Web/API).
- [Click here to see a list of already implemented APIs and how to implement one on your own.](how-to-implement-a-js-web-api.md)

## STATUS: IN-DEV
This browser can already load pages and execute their JavaScript code. Problem is that most of the JavaScript code out there
uses so called [Web-APIs](https://developer.mozilla.org/en-US/docs/Web/API), which get shipped with each browser.

This browser can already load pages and execute their JavaScript code. Problem is that most of the JavaScript code out
there uses so called [Web-APIs](https://developer.mozilla.org/en-US/docs/Web/API), which get shipped with each browser.
Every browser implements them differently, but they are more or less the same accross all browsers.

Since this projects aim is to create a new browser written in Java, completly independent from Chromium, we will need to implement those APIs
by ourselfs. It's indeed a big amount of work for one single person,
but if we work together we should be able to implement all of them within some days and make this a browser with unparalleled JavaScript support.
Since this projects aim is to create a new browser written in Java, completly independent from Chromium, we will need to
implement those APIs by ourselfs. It's indeed a big amount of work for one single person, but if we work together we
should be able to implement all of them within some days and make this a browser with unparalleled JavaScript support.

[Click here to see a list of already implemented APIs and how to implement one on your own.](how-to-implement-a-js-web-api.md)
If you are working on an implementation open an issue to keep track of who is working on what and avoid duplicate work.

## Installation
- Java 8 or higher required.
- [Click here for maven/gradle/sbt/leinigen instructions.](https://jitpack.io/#Osiris-Team/Headless-Browser)
- Make sure to watch this repository to get notified of future updates.

- Java 8 or higher required.
- [Click here for maven/gradle/sbt/leinigen instructions.](https://jitpack.io/#Osiris-Team/Headless-Browser)
- Make sure to watch this repository to get notified of future updates.

## Features

- [x] Free & Open-Source
- [x] Uses Jsoup for editing HTML directly in Java.
- [x] Uses the blazing fast GraalJS-Engine, which supports latest JavaScript code (with latest ECMA specifications).
- [x] Access to all JS-Web APIs from within Java
- [ ] Has all, standard [JavaScript Web-APIs](https://developer.mozilla.org/en-US/docs/Web/API) implemented.

## Motivation
I tried multiple different things like JCEF, Pandomium, Selenium, Selenium based maven dependencies like JWebdriver,
HtmlUnit and maybe some more I don't remember now, but all have one thing in common.
They have some kind of very nasty caveat.

I tried multiple different things like JCEF, Pandomium, Selenium, Selenium based maven dependencies like JWebdriver,
HtmlUnit and maybe some more I don't remember now, but all have one thing in common. They have some kind of very nasty
caveat.

That's why this project exists, to create a completely new browser, not dependent on Chromium or Waterfox or whatever.
We use Jsoup to handle HTML and the GraalJS engine to handle JavaScript.
Both are already working and implemented. Only thing left is implementing the JS Web-APIs.
We use Jsoup to handle HTML and the GraalJS engine to handle JavaScript. Both are already working and implemented. Only
thing left is implementing the JS Web-APIs.

## Contribute/Build

#### Beginners
If you have never contributed before, we recommend this [Beginners Article](https://www.jetbrains.com/help/idea/contribute-to-projects.html).
If you are planning to make big changes, create an issue first, where you explain what you want to do. Thank you in advance for every
contribution!
If you don't know how to import a GitHub project, check out this guide: [IntelliJ IDEA Cloning Guide](https://blog.jetbrains.com/idea/2020/10/clone-a-project-from-github/)

If you have never contributed before, we recommend
this [Beginners Article](https://www.jetbrains.com/help/idea/contribute-to-projects.html). If you are planning to make
big changes, create an issue first, where you explain what you want to do. Thank you in advance for every contribution!
If you don't know how to import a GitHub project, check out this
guide: [IntelliJ IDEA Cloning Guide](https://blog.jetbrains.com/idea/2020/10/clone-a-project-from-github/)

#### Build-Details
- Written in [Java](https://java.com/), with [JDK 8](https://www.oracle.com/java/technologies/javase/javase-jdk8-downloads.html), inside of [IntelliJ IDEA](https://www.jetbrains.com/idea/)
- Built with [Maven](https://maven.apache.org/), profiles: clean package

- Written in [Java](https://java.com/),
with [JDK 8](https://www.oracle.com/java/technologies/javase/javase-jdk8-downloads.html), inside
of [IntelliJ IDEA](https://www.jetbrains.com/idea/)
- Built with [Maven](https://maven.apache.org/), profiles: clean package

## Links
- https://spec.whatwg.org/ | Details about JS Web-APIs
- https://www.w3.org/TR/?tag=webapi | Details about JS Web-APIs

- https://spec.whatwg.org/ | Details about JS Web-APIs
- https://www.w3.org/TR/?tag=webapi | Details about JS Web-APIs

## Examples

Insert_usage_examples_here

## FAQ

Frequently_asked_questions_here

7 changes: 6 additions & 1 deletion RESEARCH.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# Research

Organized list containing easy to forget things.

## GraalJS - JavaScript Engine

Problem: `eval()` fails to detect correct binding when nested classes are used (at least in tests).

```java
Expand All @@ -18,4 +20,7 @@ public class JS_API_Test extends JavaScriptAPI {
}
}
```
Fix: Simply don't use nested classes/objects.

Fix: Simply don't use nested classes/objects.

Problem: ``
85 changes: 64 additions & 21 deletions how-to-implement-a-js-web-api.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,35 @@
# How to implement a JavaScript Web-API

1. Choose the JS Web-API you want to implement from the TODO list below, and find its documentation. The documentation can most likely be found on these websites:
1. Choose the JS Web-API you want to implement from the TODO list below, and find its documentation. The documentation
can most likely be found on these websites:
- https://www.w3.org/TR/?tag=webapi
- https://developer.mozilla.org/en-US/docs/Web/API
- https://spec.whatwg.org
3. Simply copy the [JS_API_Console](https://github.com/Osiris-Team/Headless-Browser/blob/main/src/main/java/com/osiris/headlessbrowser/javascript/apis/JS_API_Console.java)
3. Simply copy
the [JS_API_Console](https://github.com/Osiris-Team/Headless-Browser/blob/main/src/main/java/com/osiris/headlessbrowser/javascript/apis/JS_API_Console.java)
class and paste it with another name into the same package.
3. Register your new class in the [JSContext](https://github.com/Osiris-Team/Headless-Browser/blob/main/src/main/java/com/osiris/headlessbrowser/JSContext.java)
3. Register your new class in
the [JSContext](https://github.com/Osiris-Team/Headless-Browser/blob/main/src/main/java/com/osiris/headlessbrowser/JSContext.java)
class, so it gets loaded into it when the user loads a page.

## TODO
https://developer.mozilla.org/en-US/docs/Web/API
### B

## TODO

https://developer.mozilla.org/en-US/docs/Web/API

### B

- Background Fetch API
- Background Tasks
- Barcode Detection API
- Battery API
- Battery API
- Beacon
- Bluetooth API
- Broadcast Channel API

### C

- CSS Counter Styles
- CSS Font Loading API
- CSS Font Loading API
- CSS Painting API
- CSS Typed Object Model API
- CSSOM
Expand All @@ -31,41 +39,61 @@
- Contact Picker API
- Content Index API
- Credential Management API

### D

- DOM

### E

- Encoding API
- Encrypted Media Extensions

### F

- Fetch API
- File System Access API
- File and Directory Entries API
- Frame Timing API
- Fullscreen API

### G
- Gamepad API

- Gamepad API
- Geolocation API

### H

- HTML Drag and Drop API
- HTML Sanitizer API
- High Resolution Time
- History API

### I

- Image Capture API
- IndexedDB
- Intersection Observer API

### L
- Long Tasks API

- Long Tasks API

### M
- Media Capabilities API

- Media Capabilities API
- Media Capture and Streams
- Media Session API
- Media Source Extensions
- Media Source Extensions
- MediaStream Recording

### N

- Navigation Timing
- Network Information API
- Network Information API

### P

- Page Visibility API
- Payment Request API
- Performance API
Expand All @@ -75,48 +103,63 @@
- Picture-in-Picture API
- Pointer Events
- Pointer Lock API
- Presentation API
- Proximity Events
- Push API
- Presentation API
- Proximity Events
- Push API

### R

- Resize Observer API
- Resource Timing API

### S

- Screen Capture API
- Screen Wake Lock API
- Sensor API
- Server Sent Events
- Service Workers API
- Storage
- Storage Access API
- Streams
- Streams

### T

- Touch Events

### U

- URL API

### V

- Vibration API
- Visual Viewport
- Visual Viewport

### W

- Web Animations
- Web Audio API
- Web Authentication API
- Web Crypto API
- Web MIDI API
- Web Notifications
- Web Share API
- Web Speech API
- Web Speech API
- Web Storage API
- Web Workers API
- WebGL
- WebHID API
- WebRTC
- WebVR API
- WebVR API
- WebVTT
- WebXR Device API
- Websockets API

### X

- XMLHttpRequest

## DONE

- Console API
25 changes: 17 additions & 8 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.osiris.headlessbrowser</groupId>
<artifactId>Headless-Browser</artifactId>
<version>ALPHA-0.0.2</version>
<version>ALPHA-0.0.3</version>
<packaging>jar</packaging>

<name>Headless-Browser</name>
Expand All @@ -19,9 +19,16 @@

<dependencies>
<dependency>
<groupId>de.undercouch</groupId>
<artifactId>citeproc-java</artifactId>
<version>2.0.0</version>
<groupId>org.graalvm.sdk</groupId>
<artifactId>graal-sdk</artifactId>
<version>21.2.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.graalvm.js</groupId>
<artifactId>js</artifactId>
<version>21.2.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.jsoup</groupId>
Expand All @@ -37,7 +44,8 @@
</dependencies>

<build>
<finalName>${project.name}</finalName> <!-- If you'd like to have version information on your output jar, remove this. -->
<finalName>${project.name}
</finalName> <!-- If you'd like to have version information on your output jar, remove this. -->
<defaultGoal>clean package</defaultGoal>
<plugins>

Expand Down Expand Up @@ -113,7 +121,8 @@
<goal>test-resource-bundle</goal>
</goals>
<configuration>
<doclint>none</doclint> <!-- Remove this, if you want to get build errors when there is an issue with a comment/documentation. -->
<doclint>none
</doclint> <!-- Remove this, if you want to get build errors when there is an issue with a comment/documentation. -->
<detectOfflineLinks>false</detectOfflineLinks>
</configuration>
</execution>
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/osiris/headlessbrowser/HBrowser.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public HWindowBuilder openNewCustomWindow() {
* // Do stuff here...
* }
* </pre>
*
* @param HWindow
*/
public void closeWindow(HWindow HWindow) {
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/osiris/headlessbrowser/HWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public HWindow(HBrowser parentBrowser, boolean enableJavaScript, Map<String, Str

/**
* Load the contents from the provided url into the current {@link HWindow}.
*
* @param url Examples: https://www.wikipedia.org or wikipedia.org.
* @return the current {@link HWindow} for chained method calls.
* @throws IOException
Expand Down
Loading

0 comments on commit 31c62ca

Please sign in to comment.