Skip to content

docs: 📝 Added documentation for downloading Webkit for Windows #415

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .cspell/custom-dictionary.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ noreferrer
NOSONAR
osmzoom
RDWY
redist
Redistributable
Rrts
snagmp
sonarjs
Expand Down
12 changes: 12 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"@tsconfig/strictest": "^2.0.5",
"@types/arcgis-rest-api": "^10.4.8",
"@types/browser-update": "^3.3.3",
"@types/jsdom": "^21.1.7",
"@types/node": "^22.1.0",
"@vitest/coverage-istanbul": "^2.0.5",
"@vitest/coverage-v8": "^2.0.5",
Expand Down
4 changes: 4 additions & 0 deletions webkit/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
*.zip
*.part
*.zip.config
bin
28 changes: 28 additions & 0 deletions webkit/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# This folder contains files for testing with Webkit on Windows

## Download files

Follow the steps outlined in the [WebKit documentation][WebKit Windows Port].

> 1. Go to [WinCairo-64-bit-Release-Build Buildbot builder page].
> 2. Click any "Build #" which is green.
> 3. Click the "Archive" link under "compile-webkit" to download the zip
> 4. Download the corresponding release of [WebKitRequirements].
> \[You can tell which release you need by examining the `WebKitRequirementsWin64.zip.config` contained in the zip file you downloaded in step 1.\]
> 5. Unpack them, copy all DLL of WebKitRequirements to the directory of MiniBrowser.exe
> 6. Install the latest [vc_redist.x64.exe] of Microsoft Visual C++ Redistributable for Visual Studio

## TODO

- [ ] Create a script that performs the above steps.

## Sources

- [WebKit Windows Port]
- [Running the Latest Safari WebKit on Windows]

[WebKit Windows Port]: https://docs.webkit.org/Ports/WindowsPort.html#downloading-build-artifacts-from-buildbot
[WinCairo-64-bit-Release-Build Buildbot builder page]: https://build.webkit.org/#/builders/731
[WebKitRequirements]: https://github.com/WebKitForWindows/WebKitRequirements/releases
[Running the Latest Safari WebKit on Windows]: https://dev.to/dustinbrett/running-the-latest-safari-webkit-on-windows-33pb#method-2-download-build-artifacts
[vc_redist.x64.exe]: https://docs.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist
102 changes: 102 additions & 0 deletions webkit/download.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
#!/usr/bin/env bun
import { JSDOM } from "jsdom";
import fs from "node:fs/promises";
import { dirname, join } from "node:path";
import { exit, stderr } from "node:process";
import { fileURLToPath } from "node:url";

const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);

async function getHtmlContent(url: string) {
stderr.write(`\nDownloading HTML from ${url}...\n`);
const headers = new Headers({ Accept: "text/html" });
const response = await fetch(
new Request(new URL(url), {
method: "GET",
headers,
}),
);
const buffer = await response.arrayBuffer();
stderr.write(`Parsing HTML from ${url}...\n`);
const dom = new JSDOM(buffer);
return dom.window.document;
}

let url = "https://build.webkit.org/#/builders/731";
let document = await getHtmlContent(url);

/*
TODO: The content is not in the initial HTML document.
Will need to run a headless browser and wait for the document to load.
*/

function getLatestSuccessfulBuildPageUrl(document: Document) {
// Get the link to the latest successful build.
const selector = "a.bb-buildid-link > span.results_SUCCESS";
const spanContainingAnchor =
document.querySelector<HTMLSpanElement>(selector);
if (!spanContainingAnchor) {
console.error(`No element matching selector "${selector}" found`, {
anchors: [...document.querySelectorAll("span")].map((a) => a.outerHTML),
});
exit(1);
}
const anchor = spanContainingAnchor.parentElement as HTMLAnchorElement | null;

if (anchor == null) {
console.error("No anchor found");
exit(2);
}
return anchor.href;
}

// Get the contents of the link.
url = getLatestSuccessfulBuildPageUrl(document);
document = await getHtmlContent(url);

function getArchiveUrl(document: Document) {
// Get the link to the latest successful build.
const anchor = document.querySelector<HTMLAnchorElement>(
"a[href$='main.zip']",
);

if (!anchor) {
exit("No link found");
}

return anchor.href;
}

url = getArchiveUrl(document);
// Extract the filename portion of the URL.
const urlObj = new URL(url);
let filename = urlObj.pathname.split("/").pop();

if (!filename) {
exit("Could not extract filename from URL");
}

filename = join(__dirname, filename);

// Test to see if a file with this name already exists.
const alreadyExists = await fs
.access(filename)
.then(() => true)
.catch(() => false);

// Exit if the file already exists.
if (alreadyExists) {
stderr.write(`\nFile "${filename}" already exists.\n`);
exit(0);
}

// Download the archive file and save it to disk.
stderr.write(`\nDownloading "${url}"\n...`);
const response = await fetch(url);
const buffer = await response.arrayBuffer();

stderr.write(`Writing "${filename}"\n...`);
await fs.writeFile(filename, new Uint8Array(buffer));

stderr.write(`\nDone.\n`);
1 change: 1 addition & 0 deletions webkit/html.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<!DOCTYPE html><html class="no-js" ng-app="app" xmlns:ng="http://angularjs.org" xmlns:app="ignored"><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"></head><title window-title>Buildbot</title><meta name="description" content="Buildbot web UI"><meta name="viewport" content="initial-scale=1, minimum-scale=1, user-scalable=no, maximum-scale=1, width=device-width"><link href="styles.css" rel="stylesheet"><link id="bbicon" href="img/icon.png" rel="icon"><link href="img/icon.svg" title="Buildbot" rel="fluid-icon"><div id="outdated"></div><body ng-cloak><gl-page-with-sidebar><gl-topbar><gl-topbar-contextual-actions></gl-topbar-contextual-actions><loginbar></loginbar></gl-topbar><connectionstatus></connectionstatus><ui-view></ui-view></gl-page-with-sidebar></body><script src="browser-warning.js"></script><link href="browser-warning.css" rel="stylesheet"><script src="browser-warning-list.js"></script><script>window.T = {};</script><script src="scripts.js?_1617624189989"></script><script src="waterfall_view/scripts.js?_1617624189989"></script><link href="waterfall_view/styles.css?_1617624189989" rel="stylesheet"><script>angular.module('app').requires.push('waterfall_view')</script><script src="console_view/scripts.js?_1617624189989"></script><link href="console_view/styles.css?_1617624189989" rel="stylesheet"><script>angular.module('app').requires.push('console_view')</script><script src="grid_view/scripts.js?_1617624189989"></script><link href="grid_view/styles.css?_1617624189989" rel="stylesheet"><script>angular.module('app').requires.push('grid_view')</script><script>angular.module("buildbot_config", []).constant("config", {"user": {"anonymous": true}, "port": "tcp:8710:interface=127.0.0.1", "plugins": {"waterfall_view": {}, "console_view": {}, "grid_view": {}}, "auth": {"name": "GitHub", "oauth2": true, "fa_icon": "fa-github", "autologin": false}, "authz": {}, "avatar_methods": {"name": "gravatar"}, "logfileName": "http.log", "allowed_origins": ["*"], "ui_default_config": {"Builders.show_workers_name": true, "Builders.buildFetchLimit": 1000, "Workers.showWorkerBuilders": true}, "versions": [["Python", "3.9.18"], ["Buildbot", "2.10.5"], ["Twisted", "21.2.0"]], "buildbotURL": "https://build.webkit.org/", "title": "WebKit CI", "titleURL": "https://webkit.org", "multiMaster": false})</script></html>
Loading