chiark / gitweb /
wdriver: Provide WindowGuard::pieces()
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 4 Apr 2021 22:11:48 +0000 (23:11 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 5 Apr 2021 00:44:59 +0000 (01:44 +0100)
No caller yet.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
wdriver/wdriver.rs

index 3bef850035cd91e502627f95feb264545c4e82a1..8e3f0bfc6d627985201d1b0ffee4af9aee0a3b60 100644 (file)
@@ -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<WPiece> {
+    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 {