Skip to content

1.39 #51

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

Open
wants to merge 97 commits into
base: master
Choose a base branch
from
Open

1.39 #51

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
97 commits
Select commit Hold shift + click to select a range
bf33f28
driver
octaltree Jul 30, 2022
3f9f201
api.json 1.25
octaltree Jul 30, 2022
04e3ea8
find commit
octaltree Jul 31, 2022
6613826
channels
octaltree Jul 31, 2022
e7e3066
protocol.yml
octaltree Jul 31, 2022
be65435
tmp
octaltree Jul 31, 2022
cdfd728
tmp
octaltree Jul 31, 2022
55ce61b
parse api.json
octaltree Aug 2, 2022
d1403bd
todo
octaltree Aug 2, 2022
b7c14a0
parse protocol.yml
octaltree Aug 2, 2022
bc47322
all_types
octaltree Aug 2, 2022
7dd0f9a
fix
octaltree Aug 2, 2022
f816f42
collect_unnamed
octaltree Aug 3, 2022
688b805
tmp
octaltree Aug 3, 2022
9785288
tmp
octaltree Aug 3, 2022
3110961
tmp
octaltree Aug 7, 2022
9815a9b
fix
octaltree Aug 7, 2022
191a83f
tmp
octaltree Aug 7, 2022
235e21c
tmp
octaltree Aug 8, 2022
6d37aee
tmp
octaltree Aug 10, 2022
7deba2f
tmp
octaltree Aug 11, 2022
c0dc4b1
generate_protocol
octaltree Aug 13, 2022
f94daf8
fix
octaltree Aug 13, 2022
c567bb2
add generated protocol
octaltree Aug 13, 2022
30d661d
borrow
octaltree Aug 14, 2022
821b239
handle messages before shutdown
octaltree Aug 14, 2022
cb3f67d
initializer based on protocol
octaltree Aug 14, 2022
2a925fb
initialization success
octaltree Aug 14, 2022
ac86372
tmp
octaltree Aug 15, 2022
13aa2ea
tmp
octaltree Aug 20, 2022
4a72d5a
Added `commit` Document state
Aug 19, 2022
e7a8ada
Using LifecycleEvent
Aug 19, 2022
a81c7a1
Using LifecycleEvent
Aug 20, 2022
8088b0d
playwright can return response without any `params` which would break…
Aug 21, 2022
82c59b9
Fixed Page Events not detected correctly
Aug 23, 2022
7768d0b
Merge pull request #35 from tmahmood/dev
octaltree Aug 25, 2022
3960388
tmp
octaltree Aug 28, 2022
48b9788
Update utils.rs
tmahmood Aug 31, 2022
e934041
Added mime_type to File structure.
Sep 3, 2022
c7210d8
Large file upload api is now implemented. It does not replace the exi…
Sep 5, 2022
a4c4073
Fixed issue with not being able to spawn multiple playwright instances.
Sep 11, 2022
153494f
Fixed issue with not being able to spawn multiple playwright instances.
Sep 11, 2022
305f7ae
driver
octaltree Jul 30, 2022
1a965d0
api.json 1.25
octaltree Jul 30, 2022
bd65ec4
find commit
octaltree Jul 31, 2022
9dec59f
channels
octaltree Jul 31, 2022
46ee2de
protocol.yml
octaltree Jul 31, 2022
369c2ec
tmp
octaltree Jul 31, 2022
e592202
tmp
octaltree Jul 31, 2022
f4c7e6c
parse api.json
octaltree Aug 2, 2022
38de16d
todo
octaltree Aug 2, 2022
87ef5e1
parse protocol.yml
octaltree Aug 2, 2022
d0bca33
all_types
octaltree Aug 2, 2022
92b4335
fix
octaltree Aug 2, 2022
5f73be5
collect_unnamed
octaltree Aug 3, 2022
6204604
tmp
octaltree Aug 3, 2022
89027b7
tmp
octaltree Aug 3, 2022
13a91cd
tmp
octaltree Aug 7, 2022
587ea2d
fix
octaltree Aug 7, 2022
706783e
tmp
octaltree Aug 7, 2022
7a3aa88
tmp
octaltree Aug 8, 2022
fdf760a
tmp
octaltree Aug 10, 2022
0047014
tmp
octaltree Aug 11, 2022
c6eb34b
generate_protocol
octaltree Aug 13, 2022
5fb7a5d
fix
octaltree Aug 13, 2022
695f43b
add generated protocol
octaltree Aug 13, 2022
107a1d5
borrow
octaltree Aug 14, 2022
2fd9c36
handle messages before shutdown
octaltree Aug 14, 2022
a4161b8
initializer based on protocol
octaltree Aug 14, 2022
213ed4f
initialization success
octaltree Aug 14, 2022
42c9a9b
tmp
octaltree Aug 15, 2022
ecc6b09
tmp
octaltree Aug 20, 2022
a349ef1
Added `commit` Document state
Aug 19, 2022
89b429b
Using LifecycleEvent
Aug 19, 2022
aa9e8a5
Using LifecycleEvent
Aug 20, 2022
116d9a2
playwright can return response without any `params` which would break…
Aug 21, 2022
9bbef7c
Fixed Page Events not detected correctly
Aug 23, 2022
24a49c9
tmp
octaltree Aug 28, 2022
b4d1d29
tmp
octaltree Sep 4, 2022
39176ae
tmp
octaltree Sep 11, 2022
8e45f86
tmp
octaltree Sep 18, 2022
31cd955
model
octaltree Sep 19, 2022
0ca7aac
builder
octaltree Sep 24, 2022
2d2073e
builder
octaltree Sep 24, 2022
7285f5a
impl builder
octaltree Sep 25, 2022
9e97665
Merge branch '1.25' into dev
Oct 14, 2022
cdeabd2
Updated ConsoleMessage Structure to match with latest playwright version
tmahmood Apr 19, 2023
cde0f1c
Incorporated Randall's Windows Related Changes
tmahmood Apr 19, 2023
8e5e8d6
Update playwright version to: 1.31.0-alpha-feb-1-2023
Oct 14, 2022
d4cd5ea
Fixed: When using `persistent_context_launcher` `set_input_file_paths…
tmahmood Mar 14, 2023
27e1401
Incorporated Randall's Windows bug fix
tmahmood Apr 8, 2023
03d2970
Updated ConsoleMessage Structure to match with latest playwright version
tmahmood Apr 18, 2023
836ddbc
Updated connection.rs to fix parking_lot related issue
tmahmood Apr 19, 2023
9425bc3
Update github action, using nightly
tmahmood May 1, 2023
c7e8ee8
Removed a println!
tmahmood May 12, 2023
c82b2c0
Prepare 1.39 upgrade ; fix base64 deprecation error ; rustfmt
SamuelMarks Oct 30, 2023
a73c5b9
Run scripts make and fix rustfmt issues in generate_api.rs
SamuelMarks Oct 31, 2023
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: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
- name: Install latest nightly
uses: actions-rs/toolchain@v1
with:
toolchain: stable
toolchain: nightly
override: true
components: rustfmt, clippy

Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,7 @@ target
Cargo.lock
driver
tarpaulin-report.html
/.idea/
/playwright-rust-randall.iml
/scripts/scripts.iml
/src/api/generated.rs
2 changes: 1 addition & 1 deletion .rustfmt.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
edition = "2018"
edition = "2021"
unstable_features = true
fn_single_line = true
trailing_comma = "Never"
Expand Down
13 changes: 7 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ documentation = "https://docs.rs/playwright/"
repository = "https://github.com/octaltree/playwright-rust"
categories = ["web-programming"]
keywords = ["testing", "headless", "web", "browser", "automation"]
edition = "2018"
edition = "2021"
build = "src/build.rs"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
Expand All @@ -20,23 +20,24 @@ reqwest = { version = "0.11.4", features = ["blocking"] }
log = "0.4.14"
serde = { version = "1.0.126", features = ["derive"] }
serde_json = "1.0.66"
zip = "0.5.13"
zip = "0.6.4"
thiserror = "1.0.26"
strong = { version = "0.3.4", features = ["serde", "shorthand"] }
tokio = { version = "1.9.0", features = ["sync", "rt-multi-thread", "macros"] }
actix-rt = { version = "2.2.0", optional = true }
async-std = { version = "1.9.0", features = ["attributes"], optional = true }
dirs = "3.0.2"
dirs = "5.0.0"
paste = "1.0.5"
base64 = "0.13.0"
base64 = "0.21.0"
itertools = "0.10.1"
chrono = { version = "0.4.19", optional = true, features = ["serde"] }
tokio-stream = { version = "0.1.7", features = ["sync"] }
futures = "0.3.16"
serde_with = { version = "1.9.4", default-features = false, features = ["macros"] }
serde_with = { version = "2.3.2", default-features = false, features = ["macros"] }
parking_lot = "0.12.1"

[dev-dependencies]
env_logger = "0.9.0"
env_logger = "0.10.0"
tempdir = "0.3.7"
tide = "0.16.0"
warp = "0.3.1"
Expand Down
10 changes: 8 additions & 2 deletions scripts/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,20 @@ edition = "2018"
[dependencies]
anyhow = "1.0.41"
case = "1.0.0"
itertools = "0.10.3"
proc-macro2 = "1.0.27"
quote = "1.0.9"
serde = { version = "1.0.126", features = ["derive"] }
serde_json = "1.0.64"
serde_yaml = "0.9.2"

[[bin]]
name = "gen"
path = "src/gen.rs"
name = "generate_api"
path = "src/generate_api.rs"

[[bin]]
name = "generate_protocol"
path = "src/generate_protocol.rs"

[[bin]]
name = "diff"
Expand Down
24 changes: 20 additions & 4 deletions scripts/Makefile
Original file line number Diff line number Diff line change
@@ -1,9 +1,25 @@
../src/api/generated.rs: ../src/api/api.json
rustfmt --emit stdout <(cargo run --bin gen < $^)| tail +3 > $@
sed -i 's/\[actionability\](.\/actionability.md)/[actionability](https:\/\/playwright.dev\/docs\/actionability\/)/g' $@
.PHONY: clean nop
nop:

SRC=$(shell find src)

clean_driver:
rm -r /tmp/build-playwright-rust
rm -r ~/.cache/ms-playwright/playwright-rust

../src/api/api.json: ../src/build.rs
cd .. && cargo run print-api-json |jq > src/api/api.json

../src/protocol/protocol.yml: ../src/api/api.json
cp ~/.cache/ms-playwright/playwright-rust/driver/package/protocol.yml $@

../src/api/generated.rs: ../src/api/api.json ${SRC}
cargo run --bin generate_api < $< > $@
rustfmt +nightly --config-path ../.rustfmt.toml $@

../src/protocol/generated.rs: ../src/protocol/protocol.yml ${SRC}
cat $<| sed 's#null#"null"#'| cargo run --bin generate_protocol > $@
rustfmt +nightly --config-path ../.rustfmt.toml $@

diff:
cargo run --bin diff <(git show master:src/api/api.json) <(git show HEAD:src/api/api.json)
cargo run --bin diff <(git show master:src/api/api.json) ../src/api/api.json
20 changes: 20 additions & 0 deletions scripts/driver_commit.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash
# find commit corresponding to the driver
# use in latest main of playwright

function check(){
[ `same_protocol` -ne 0 ] || [ `same_api` -ne 0 ]
}

function same_protocol(){
diff ~/.cache/ms-playwright/playwright-rust/driver/package/protocol.yml packages/playwright-core/src/protocol/protocol.yml| wc -l
}

function same_api(){
API_JSON_MODE=1 node utils/doclint/generateApiJson.js > ./output/api.json
diff ~/.cache/ms-playwright/playwright-rust/driver/package/api.json output/api.json| wc -l
}

while check; do
git checkout HEAD~
done
214 changes: 214 additions & 0 deletions scripts/src/api.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,214 @@
pub mod types;

use serde::{Deserialize, Deserializer, Serialize};

#[derive(Debug, Deserialize)]
#[serde(transparent)]
pub struct Api(pub Vec<Interface>);

#[derive(Debug, Deserialize)]
pub struct Interface {
pub name: String,
// langs
//#[serde(default)]
// pub comment: String,
pub spec: Vec<SpecNode>,
pub members: Vec<Member>,
pub extends: Option<String>
}

/// ex. {"name": "toMatchSnapshot#2", "alias": "toMatchSnapshot", "overloadIndex": 1}
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Member {
pub kind: Kind,
pub name: String,
pub alias: String,
pub experimental: bool,
pub since: String,
pub overload_index: usize,
pub required: bool,
#[serde(rename = "async")]
pub is_async: bool,
pub args: Vec<Arg>,
#[serde(rename = "type")]
pub ty: Type,
// langs
// paramOrOption null
#[serde(default)]
#[serde(deserialize_with = "string_as_bool")]
pub deprecated: bool,
//#[serde(default)]
// pub comment: String,
pub spec: Vec<SpecNode>
}

fn string_as_bool<'de, D>(deserializer: D) -> Result<bool, D::Error>
where
D: Deserializer<'de>,
{
let s = <String as Deserialize>::deserialize(deserializer);
Ok(match s {
Err(_) => false,
_ => true
})
}


#[derive(Debug, Deserialize, PartialEq, Eq, Clone, Copy)]
#[serde(rename_all = "camelCase")]
pub enum Kind {
Event,
Method,
Property
}

#[derive(Debug, PartialEq, Deserialize, Serialize, Eq, Clone)]
pub struct Type {
pub name: String,
#[serde(default)]
pub expression: Option<String>,
#[serde(default)]
pub properties: Vec<Arg>,
#[serde(default)]
pub templates: Vec<Type>,
#[serde(default)]
pub union: Vec<Type>
}

#[derive(Debug, PartialEq, Deserialize, Serialize, Eq, Clone)]
#[serde(rename_all = "camelCase")]
pub struct Arg {
pub name: String,
pub kind: ArgKind,
pub alias: String,
#[serde(rename = "type")]
pub ty: Type,
pub langs: Langs,
// experimental
// paramOrOption
pub since: String,
pub overload_index: usize,
// pub comment: String,
#[serde(default)]
pub spec: Vec<SpecNode>,
pub required: bool,
#[serde(default)]
#[serde(deserialize_with = "string_as_bool")]
pub deprecated: bool,
#[serde(rename = "async")]
pub is_async: bool
}

#[derive(Debug, Deserialize, Serialize, PartialEq, Eq, Clone, Copy)]
#[serde(rename_all = "camelCase")]
pub enum ArgKind {
Property
}

#[derive(Debug, Deserialize, Serialize, PartialEq, Eq, Clone)]
#[serde(tag = "type")]
#[serde(rename_all = "camelCase")]
pub enum SpecNode {
Text {
text: String
},
Code {
#[serde(rename = "codeLang")]
lang: String,
lines: Vec<String>
},
Li {
#[serde(rename = "liType")]
li_type: LiType,
text: String
},
Note {
#[serde(rename = "noteType")]
note_type: NoteType,
text: String
}
}

#[derive(Debug, Deserialize, Serialize, PartialEq, Eq, Clone, Copy)]
#[serde(rename_all = "camelCase")]
pub enum LiType {
Bullet,
Ordinal
}

#[derive(Debug, Deserialize, Serialize, PartialEq, Eq, Clone, Copy)]
#[serde(rename_all = "camelCase")]
pub enum NoteType {
#[serde(rename = "caution Discouraged")]
CautionDiscouraged,
Caution,
Note,
Warning
}

#[derive(Debug, Deserialize, Serialize, PartialEq, Eq, Clone)]
#[serde(rename_all = "camelCase")]
pub struct Langs {
pub only: Option<Vec<String>>
}

#[cfg(test)]
mod tests {
use super::*;
use std::fs;

#[test]
fn all_api_types() {
let mut types = Vec::new();
fn add<'a>(dest: &mut Vec<&'a Type>, t: &'a Type) {
let Type {
name,
expression: _,
properties,
templates,
union
}: &Type = t;
dest.push(t);
for arg in properties {
add(dest, &arg.ty);
}
for ty in templates {
add(dest, ty);
}
for ty in union {
add(dest, ty);
}
}
let s = fs::read_to_string("../src/api/api.json").unwrap();
let api: Api = serde_json::from_str(&s).unwrap();
for interface in &api.0 {
for member in &interface.members {
for arg in &member.args {
add(&mut types, &arg.ty);
}
add(&mut types, &member.ty);
}
}
println!("{}", serde_json::to_string(&types).unwrap());
}

#[test]
fn parse() {
let xs:Vec<SpecNode> = serde_json::from_str(r#"
[{
"type": "text",
"text": "Captures the current state of the accessibility tree. The returned object represents the root accessible node of the page."
},
{
"type": "note",
"noteType": "note",
"text": "The Chromium accessibility tree contains nodes that go unused on most platforms and by most screen readers. Playwright will discard them as well for an easier to process tree, unless `interestingOnly` is set to `false`."
},
{
"type": "text",
"text": "An example of dumping the entire accessibility tree:"
}]
"#).unwrap();
}
}
Loading