From: Ian Jackson Date: Sun, 4 Apr 2021 22:11:48 +0000 (+0100) Subject: wdriver: Provide WindowGuard::pieces() X-Git-Tag: otter-0.5.0~196 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=83c0d7685d9a1e9ac1a30c5f2c6efb96112c38aa;p=otter.git wdriver: Provide WindowGuard::pieces() No caller yet. Signed-off-by: Ian Jackson --- diff --git a/wdriver/wdriver.rs b/wdriver/wdriver.rs index 3bef8500..8e3f0bfc 100644 --- a/wdriver/wdriver.rs +++ b/wdriver/wdriver.rs @@ -64,6 +64,8 @@ pub struct Window { } #[derive(Debug,Clone,Eq,PartialEq,Ord,PartialOrd,Hash)] +#[derive(Deserialize)] +#[serde(transparent)] pub struct Vpid(pub String); impl Display for Vpid { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.write_str(&self.0) } @@ -252,6 +254,12 @@ impl Debug for WindowGuard<'_> { } } +#[derive(Deserialize,Clone,Debug)] +pub struct WPiece { + piece: Vpid, + p: JsV, +} + impl<'g> WindowGuard<'g> { #[throws(AE)] pub fn piece_vpid(&'g self, some_pieceid: &'_ str) -> Vpid { @@ -658,6 +666,25 @@ impl<'g> WindowGuard<'g> { })() .context("check for in-client trapped errors")?; } + + /// These come in stacking order, bottom to top. + #[throws(AE)] + pub fn pieces(&mut self) -> Vec { + self.su.driver.execute_script(r#" + let uelem = pieces_marker; + let out = []; + for (;;) { + uelem = uelem.nextElementSibling; + let piece = uelem.dataset.piece; + if (!piece) break; + let p = pieces[piece]; + out.push({ piece: piece, p: p }); + } + return out; + "#) + .did("fetch ids")? + .convert()? + } } impl Drop for FinalInfoCollection {