Skip to content
Merged
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
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ And Lightpanda commit [b846541ff69082f4d283155f0b3651ae0394a240](https://github.
### Execution time

```console
$ hyperfine --warmup 3 --runs 20 --shell=none "google-chrome --user-data-dir=/tmp/bench_chrome --headless=new --dump-dom http://127.0.0.1:124/campfire-commerce/" "./lightpanda --dump http://127.0.0.1:1234/campfire-commerce/"
Benchmark 1: google-chrome --user-data-dir=/tmp/bench_chrome --headless=new --dump-dom http://127.0.0.1:124/campfire-commerce/
$ hyperfine --warmup 3 --runs 20 --shell=none "google-chrome --user-data-dir=/tmp/bench_chrome --headless=new --dump-dom http://127.0.0.1:1234/campfire-commerce/" "./lightpanda --dump http://127.0.0.1:1234/campfire-commerce/"
Benchmark 1: google-chrome --user-data-dir=/tmp/bench_chrome --headless=new --dump-dom http://127.0.0.1:1234/campfire-commerce/
Time (mean ± σ): 598.7 ms ± 8.6 ms [User: 348.0 ms, System: 165.1 ms]
Range (min … max): 586.3 ms … 611.9 ms 20 runs

Expand All @@ -88,7 +88,7 @@ Benchmark 2: ./lightpanda --dump http://127.0.0.1:1234/campfire-commerce/

Summary
'./lightpanda --dump http://127.0.0.1:1234/campfire-commerce/' ran
30.50 ± 0.49 times faster than 'google-chrome --user-data-dir=/tmp/bench_chrome --headless=new --dump-dom http://127.0.0.1:124/campfire-commerce/'
30.50 ± 0.49 times faster than 'google-chrome --user-data-dir=/tmp/bench_chrome --headless=new --dump-dom http://127.0.0.1:1234/campfire-commerce/'
```

![aws.m5 hyperfine](./img/aws_m5_hyperfine.png)
Expand Down
179 changes: 49 additions & 130 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@
"homepage": "https://lightpanda.io",
"dependencies": {
"playwright": "^1.42.1",
"puppeteer-core": "^22.15.0"
"puppeteer-core": "^24.10.1"
}
}
52 changes: 52 additions & 0 deletions puppeteer/cookies.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// Copyright 2023-2025 Lightpanda (Selecy SAS)
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
'use scrict'

import puppeteer from 'puppeteer-core';

const browserAddress = process.env.BROWSER_ADDRESS ? process.env.BROWSER_ADDRESS : 'ws://127.0.0.1:9222';
const url = process.env.URL ? process.env.URL : 'http://127.0.0.1:1234/campfire-commerce/';

// use browserWSEndpoint to pass the Lightpanda's CDP server address.
const browser = await puppeteer.connect({
browserWSEndpoint: browserAddress,
});
// The rest of your script remains the same.
const context = await browser.createBrowserContext();
const page = await context.newPage();

const relevant_cookie = {name: 'left', value: 'right', url: "http://127.0.0.1:1234/"};
const irrelevant_cookie = {name: 'uo', value: 'down', url: "https://lightpanda.io/"};
await context.setCookie(relevant_cookie, irrelevant_cookie);

await page.goto(url, {waitUntil: 'load'});

const found_cookies = await context.cookies();
for (const cookie of found_cookies) {
const { name, ...details } = cookie
console.log(`Cookie: ${name} = ${JSON.stringify(details)}`);
}
if (found_cookies.length != 2) {
throw new Error("Wrong number of cookies found");
}

context.deleteCookie(irrelevant_cookie);
const found_cookies2 = await context.cookies();
if (found_cookies2.length != 1 && found_cookies2[0].name !== relevant_cookie.name || found_cookies2[0].value !== relevant_cookie.value) {
throw new Error("Cookie does not match the expected values");
}

await page.close();
await context.close();
await browser.disconnect();
1 change: 1 addition & 0 deletions runner/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ func run(ctx context.Context, args []string, stdout, stderr io.Writer) error {
{Bin: "node", Args: []string{"puppeteer/dynamic_scripts.js"}},
{Bin: "node", Args: []string{"puppeteer/location_write.js"}},
{Bin: "node", Args: []string{"puppeteer/form.js"}},
{Bin: "node", Args: []string{"puppeteer/cookies.js"}},
{Bin: "node", Args: []string{"playwright/connect.js"}},
{Bin: "node", Args: []string{"playwright/cdp.js"}, Env: []string{"RUNS=2"}},
{Bin: "node", Args: []string{"playwright/dump.js"}},
Expand Down