Skip to content

The headless browser for AI agents and web scraping

fix(cssom): use owning frame state and invalidate resized styles

SGavrlf32db47da629
diff --git a/crates/obscura-js/js/bootstrap.js b/crates/obscura-js/js/bootstrap.js
index 9039074a..f93bafcd 100644
--- a/crates/obscura-js/js/bootstrap.js
+++ b/crates/obscura-js/js/bootstrap.js
@@ -4950,7 +4950,7 @@ class Element extends Node {
_renderBoxMetrics() {
if (typeof __obscuraCore.ops.op_layout_box_metrics === 'function') {
try {
- const raw = __obscuraCore.ops.op_layout_box_metrics(String(this._nid | 0));
+ const raw = __obscuraCore.ops.op_layout_box_metrics(String(this._nid | 0), _realmFrameId);
if (!raw) return { clientWidth: 0, clientHeight: 0, offsetWidth: 0, offsetHeight: 0 };
const metrics = JSON.parse(raw);
if (metrics && Number.isFinite(metrics.clientWidth)
@@ -4969,7 +4969,7 @@ class Element extends Node {
}
if (typeof __obscuraCore.ops.op_layout_geometry !== 'function') return null;
try {
- const raw = __obscuraCore.ops.op_layout_geometry(String(this._nid | 0));
+ const raw = __obscuraCore.ops.op_layout_geometry(String(this._nid | 0), _realmFrameId);
if (!raw) return { width: 0, height: 0 };
const geometry = JSON.parse(raw);
if (geometry
@@ -4996,7 +4996,7 @@ class Element extends Node {
_renderBoxGeometry() {
if (typeof __obscuraCore.ops.op_layout_geometry !== 'function') return undefined;
try {
- const raw = __obscuraCore.ops.op_layout_geometry(String(this._nid | 0));
+ const raw = __obscuraCore.ops.op_layout_geometry(String(this._nid | 0), _realmFrameId);
if (!raw) return null;
const geometry = JSON.parse(raw);
if (geometry
@@ -5060,7 +5060,7 @@ class Element extends Node {
_renderScrollMetrics() {
if (typeof __obscuraCore.ops.op_layout_metrics !== 'function') return null;
try {
- const raw = __obscuraCore.ops.op_layout_metrics();
+ const raw = __obscuraCore.ops.op_layout_metrics(_realmFrameId);
return raw ? JSON.parse(raw) : null;
} catch (_e) {
return null;
@@ -5069,7 +5069,7 @@ class Element extends Node {
_renderElementScrollMetrics() {
if (typeof __obscuraCore.ops.op_element_scroll_metrics !== 'function') return undefined;
try {
- const raw = __obscuraCore.ops.op_element_scroll_metrics(String(this._nid | 0));
+ const raw = __obscuraCore.ops.op_element_scroll_metrics(String(this._nid | 0), _realmFrameId);
if (!raw) return null;
const metrics = JSON.parse(raw);
return metrics && metrics.hasBox !== false ? metrics : null;
@@ -5080,7 +5080,7 @@ class Element extends Node {
_renderScrollOffset() {
if (typeof __obscuraCore.ops.op_scroll_offset !== 'function') return null;
try {
- const raw = __obscuraCore.ops.op_scroll_offset();
+ const raw = __obscuraCore.ops.op_scroll_offset(_realmFrameId);
return raw ? JSON.parse(raw) : null;
} catch (_e) {
return null;
@@ -5089,7 +5089,7 @@ class Element extends Node {
_setRenderScroll(x, y) {
if (typeof __obscuraCore.ops.op_scroll_to !== 'function') return null;
try {
- const raw = __obscuraCore.ops.op_scroll_to(+x || 0, +y || 0);
+ const raw = __obscuraCore.ops.op_scroll_to(+x || 0, +y || 0, _realmFrameId);
return raw ? JSON.parse(raw) : null;
} catch (_e) {
return null;
@@ -5098,7 +5098,7 @@ class Element extends Node {
_setRenderElementScroll(x, y) {
if (typeof __obscuraCore.ops.op_element_scroll_to !== 'function') return null;
try {
- const raw = __obscuraCore.ops.op_element_scroll_to(String(this._nid | 0), +x || 0, +y || 0);
+ const raw = __obscuraCore.ops.op_element_scroll_to(String(this._nid | 0), +x || 0, +y || 0, _realmFrameId);
return raw ? JSON.parse(raw) : null;
} catch (_e) {
return null;
@@ -8400,7 +8400,7 @@ function _roMeasurement(target, suppliedGeometry, suppliedByBatch = false) {
const hasRenderer = typeof __obscuraCore.ops.op_layout_geometry === "function";
if (!suppliedByBatch && hasRenderer && target?._nid != null) {
try {
- const raw = __obscuraCore.ops.op_layout_geometry(String(target._nid | 0));
+ const raw = __obscuraCore.ops.op_layout_geometry(String(target._nid | 0), _realmFrameId);
geometry = raw ? JSON.parse(raw) : null;
} catch (_error) {}
}
@@ -8502,7 +8502,7 @@ function _roMeasurements(targets) {
if (typeof bulk === "function"
&& targets.every(target => target?._nid != null)) {
try {
- const raw = bulk(JSON.stringify(targets.map(target => target._nid | 0)));
+ const raw = bulk(JSON.stringify(targets.map(target => target._nid | 0)), _realmFrameId);
const geometries = raw ? JSON.parse(raw) : null;
if (Array.isArray(geometries) && geometries.length === targets.length) {
for (let index = 0; index < targets.length; index++) {
@@ -8893,13 +8893,20 @@ globalThis.matchMedia = _markNative(function matchMedia(q) {
};
});
// getComputedStyle() returns a fresh declaration object, but those objects all
-// observe the same computed style for an element until the document mutates.
+// observe the same computed style until the document or viewport changes.
// Share the immutable native snapshot behind them. Frameworks routinely call
// getComputedStyle() repeatedly on the same few roots; rebuilding and parsing
// several hundred properties for every wrapper dominated real-page startup.
const _computedStyleSnapshotCache = new WeakMap();
globalThis.getComputedStyle = (el, pseudo = '') => {
if (!el) el = document.body || {};
+ // Resolve foreign elements in their document's realm, including its live
+ // mutation epoch. Node ids and style caches are document-local.
+ const view = el.ownerDocument?.defaultView;
+ if (view && view !== globalThis && typeof view.getComputedStyle === 'function'
+ && view.getComputedStyle !== globalThis.getComputedStyle) {
+ return view.getComputedStyle(el, pseudo);
+ }
pseudo = String(pseudo || '').toLowerCase();
const style = el?.style || el?._style || new CSSStyleDeclaration();
// Render builds expose one immutable snapshot from the retained final
@@ -8908,21 +8915,25 @@ globalThis.getComputedStyle = (el, pseudo = '') => {
const cacheable = (typeof el === 'object' && el !== null) || typeof el === 'function';
let snapshot = !pseudo && cacheable ? _computedStyleSnapshotCache.get(el) : null;
if (!snapshot) {
- snapshot = { rendered: null, epoch: -1, names: [], complete: false };
+ snapshot = { rendered: null, epoch: -1, viewportWidth: -1, viewportHeight: -1, names: [], complete: false };
if (!pseudo && cacheable) _computedStyleSnapshotCache.set(el, snapshot);
}
const refreshRendered = (property = '') => {
+ const viewportWidth = globalThis.innerWidth, viewportHeight = globalThis.innerHeight;
const hasRunningAnimation = typeof _animationsForTarget === 'function'
&& _animationsForTarget(el).some(animation => animation.playState === 'running');
if (snapshot.epoch === _domMutationEpoch && !hasRunningAnimation
+ && snapshot.viewportWidth === viewportWidth && snapshot.viewportHeight === viewportHeight
&& (snapshot.complete || (property && snapshot.rendered
&& Object.prototype.hasOwnProperty.call(snapshot.rendered, property)))) return;
snapshot.epoch = _domMutationEpoch;
+ snapshot.viewportWidth = viewportWidth;
+ snapshot.viewportHeight = viewportHeight;
snapshot.rendered = null;
snapshot.complete = true;
if (typeof __obscuraCore.ops.op_computed_style === 'function' && el?._nid != null) {
try {
- const raw = __obscuraCore.ops.op_computed_style(String(el._nid | 0), pseudo, property);
+ const raw = __obscuraCore.ops.op_computed_style(String(el._nid | 0), pseudo, property, _realmFrameId);
if (raw) [snapshot.complete, snapshot.rendered] = JSON.parse(raw);
} catch (e) {}
}
@@ -10114,7 +10125,7 @@ function _ioMeasurements(elements) {
const nativeElements = elements.filter(element => element?._nid != null);
if (typeof bulk !== "function" || !nativeElements.length) return measurements;
try {
- const raw = bulk(JSON.stringify(nativeElements.map(element => element._nid | 0)));
+ const raw = bulk(JSON.stringify(nativeElements.map(element => element._nid | 0)), _realmFrameId);
const geometries = raw ? JSON.parse(raw) : null;
if (Array.isArray(geometries) && geometries.length === nativeElements.length) {
for (let index = 0; index < nativeElements.length; index++) {
@@ -16084,7 +16095,7 @@ if (typeof Document !== 'undefined' && !Document.prototype.elementFromPoint) {
var h = (typeof window !== 'undefined' && window.innerHeight) || 720;
if (x < 0 || y < 0 || x > w || y > h) return null;
if (typeof __obscuraCore.ops.op_layout_hit_test === 'function') {
- var hitNid = __obscuraCore.ops.op_layout_hit_test(x, y);
+ var hitNid = __obscuraCore.ops.op_layout_hit_test(x, y, _realmFrameId);
if (hitNid >= 0) {
var hit = _wrapEl(hitNid);
return hit === this.documentElement && this.body ? this.body : hit;
diff --git a/crates/obscura-js/src/frame.rs b/crates/obscura-js/src/frame.rs
index f50aaa31..c46efda5 100644
--- a/crates/obscura-js/src/frame.rs
+++ b/crates/obscura-js/src/frame.rs
@@ -204,6 +204,12 @@ impl FrameRealm {
} else {
150.0
};
+ #[cfg(feature = "render")]
+ {
+ let state = self.realms.borrow().by_frame_id(self.frame_id)
+ .ok_or_else(|| "could not resize frame: missing realm".to_string())?;
+ state.borrow_mut().set_viewport(width, height);
+ }
self.execute_script(
parent,
&format!(
@@ -588,6 +594,32 @@ mod tests {
);
}
+ #[cfg(feature = "render")]
+ #[test]
+ fn frame_renderer_viewport_changes_do_not_resize_the_page() {
+ let mut parent = page("https://parent.example/",
+ "<html><head><style>body{margin:0}#page{width:100vw;height:100vh}</style></head><body><div id='page'></div></body></html>");
+ let frame = FrameRealm::new(&mut parent, 1, 0, "https://child.example/",
+ "<html><head><style>body{margin:0}div{width:50vw;height:25vh}</style></head><body><div id='box'></div></body></html>").unwrap();
+ frame.set_viewport(&mut parent, 300.0, 80.0).unwrap();
+ assert_eq!(frame.evaluate(&mut parent, r#"(() => {
+ const r = document.getElementById('box').getBoundingClientRect();
+ globalThis.savedStyle = getComputedStyle(document.getElementById('box'));
+ return [r.width, r.height, savedStyle.width, savedStyle.height];
+ })()"#).unwrap(), serde_json::json!([150, 20, "150px", "20px"]));
+ frame.set_viewport(&mut parent, 200.0, 120.0).unwrap();
+ assert_eq!(frame.evaluate(&mut parent, r#"(() => {
+ const r = document.getElementById('box').getBoundingClientRect();
+ const fresh = getComputedStyle(document.getElementById('box'));
+ return [r.width, r.height, savedStyle.width, savedStyle.height,
+ fresh.width, fresh.height];
+ })()"#).unwrap(), serde_json::json!([100, 30, "100px", "30px", "100px", "30px"]));
+ assert_eq!(parent.evaluate(r#"(() => {
+ const r = document.getElementById('page').getBoundingClientRect();
+ return [r.width, r.height];
+ })()"#).unwrap(), serde_json::json!([1280, 720]));
+ }
+
/// A frame must not look like a different browser than its parent. Anti-bot
/// code fingerprints inside the frame and compares it with the top document.
#[tokio::test(flavor = "current_thread")]
diff --git a/crates/obscura-js/src/ops.rs b/crates/obscura-js/src/ops.rs
index 77963b68..334b90e7 100644
--- a/crates/obscura-js/src/ops.rs
+++ b/crates/obscura-js/src/ops.rs
@@ -476,6 +476,16 @@ impl ObscuraState {
document_write_inserted_script: Cell::new(false),
}
}
+ #[cfg(feature = "render")]
+ pub(crate) fn set_viewport(&mut self, width: f64, height: f64) {
+ let viewport = (width as f32, height as f32);
+ if self.viewport != viewport {
+ self.viewport = viewport;
+ self.prepared_render = None;
+ self.pending_style_mutations.clear();
+ self.resolved_scroll = None;
+ }
+ }
}
#[derive(Debug, Clone)]
@@ -5479,6 +5489,8 @@ fn op_initial_frame(
}
context.set_security_token(parent_context.get_security_token(scope));
let mut child = ObscuraState::new();
+ #[cfg(feature = "render")]
+ child.set_viewport(300.0, 150.0);
{
let parent = parent_state.borrow();
child.dom = Some(obscura_dom::parse_html(
@@ -7405,8 +7417,8 @@ fn clamp_scroll_offset_for_consumer(
#[cfg(feature = "render")]
#[op2]
#[string]
-fn op_layout_geometry(state: &OpState, #[string] nid_str: String) -> String {
- let shared = state.borrow::<SharedState>().clone();
+fn op_layout_geometry(state: &OpState, #[string] nid_str: String, frame_id: u32) -> String {
+ let shared = frame_state(state, frame_id);
let nid: u32 = nid_str.parse().unwrap_or(0);
let nid = obscura_dom::tree::NodeId::new(nid);
let mut gs = shared.borrow_mut();
@@ -7462,8 +7474,8 @@ fn op_layout_geometry(state: &OpState, #[string] nid_str: String) -> String {
#[cfg(feature = "render")]
#[op2]
#[string]
-fn op_layout_box_metrics(state: &OpState, #[string] nid_str: String) -> String {
- let shared = state.borrow::<SharedState>().clone();
+fn op_layout_box_metrics(state: &OpState, #[string] nid_str: String, frame_id: u32) -> String {
+ let shared = frame_state(state, frame_id);
let nid = NodeId::new(nid_str.parse().unwrap_or(0));
let mut gs = shared.borrow_mut();
sample_live_document_animations(&mut gs);
@@ -7489,8 +7501,8 @@ fn op_layout_box_metrics(state: &OpState, #[string] nid_str: String) -> String {
/// point is outside the viewport or no rendered element contains it.
#[cfg(feature = "render")]
#[op2(fast)]
-fn op_layout_hit_test(state: &OpState, x: f64, y: f64) -> i32 {
- let shared = state.borrow::<SharedState>().clone();
+fn op_layout_hit_test(state: &OpState, x: f64, y: f64, frame_id: u32) -> i32 {
+ let shared = frame_state(state, frame_id);
let mut gs = shared.borrow_mut();
sample_live_document_animations(&mut gs);
if ensure_resolved_scroll_for_geometry(&mut gs).is_none() {
@@ -7523,13 +7535,13 @@ fn op_layout_hit_test(state: &OpState, x: f64, y: f64) -> i32 {
#[cfg(feature = "render")]
#[op2]
#[string]
-fn op_resize_observer_measurements(state: &OpState, #[string] nids_json: String) -> String {
+fn op_resize_observer_measurements(state: &OpState, #[string] nids_json: String, frame_id: u32) -> String {
let nids = serde_json::from_str::<Vec<u32>>(&nids_json).unwrap_or_default();
if nids.is_empty() {
return "[]".to_string();
}
- let shared = state.borrow::<SharedState>().clone();
+ let shared = frame_state(state, frame_id);
let mut gs = shared.borrow_mut();
sample_live_document_animations(&mut gs);
if ensure_resolved_scroll_for_geometry(&mut gs).is_none() {
@@ -7588,13 +7600,13 @@ fn op_resize_observer_measurements(state: &OpState, #[string] nids_json: String)
#[cfg(feature = "render")]
#[op2]
#[string]
-fn op_intersection_observer_measurements(state: &OpState, #[string] nids_json: String) -> String {
+fn op_intersection_observer_measurements(state: &OpState, #[string] nids_json: String, frame_id: u32) -> String {
let nids = serde_json::from_str::<Vec<u32>>(&nids_json).unwrap_or_default();
if nids.is_empty() {
return "[]".to_string();
}
- let shared = state.borrow::<SharedState>().clone();
+ let shared = frame_state(state, frame_id);
let mut gs = shared.borrow_mut();
sample_live_document_animations(&mut gs);
if ensure_resolved_scroll_for_geometry(&mut gs).is_none() {
@@ -7648,8 +7660,9 @@ fn op_computed_style(
#[string] nid_str: String,
#[string] pseudo: String,
#[string] property: String,
+ frame_id: u32,
) -> String {
- let shared = state.borrow::<SharedState>().clone();
+ let shared = frame_state(state, frame_id);
let nid: u32 = nid_str.parse().unwrap_or(0);
let nid = obscura_dom::tree::NodeId::new(nid);
let mut gs = shared.borrow_mut();
@@ -7728,8 +7741,8 @@ fn op_css_supports(#[string] name: &str, #[string] value: &str) -> bool {
#[cfg(feature = "render")]
#[op2]
#[string]
-fn op_layout_metrics(state: &OpState) -> String {
- let shared = state.borrow::<SharedState>().clone();
+fn op_layout_metrics(state: &OpState, frame_id: u32) -> String {
+ let shared = frame_state(state, frame_id);
let mut gs = shared.borrow_mut();
sample_live_document_animations(&mut gs);
let viewport = gs.viewport;
@@ -7745,8 +7758,8 @@ fn op_layout_metrics(state: &OpState) -> String {
#[cfg(feature = "render")]
#[op2]
#[string]
-fn op_element_scroll_metrics(state: &OpState, #[string] nid_str: String) -> String {
- let shared = state.borrow::<SharedState>().clone();
+fn op_element_scroll_metrics(state: &OpState, #[string] nid_str: String, frame_id: u32) -> String {
+ let shared = frame_state(state, frame_id);
let nid = NodeId::new(nid_str.parse().unwrap_or(0));
let mut gs = shared.borrow_mut();
sample_live_document_animations(&mut gs);
@@ -7782,8 +7795,8 @@ fn op_element_scroll_metrics(state: &OpState, #[string] nid_str: String) -> Stri
#[cfg(feature = "render")]
#[op2]
#[string]
-fn op_element_scroll_to(state: &OpState, #[string] nid_str: String, x: f64, y: f64) -> String {
- let shared = state.borrow::<SharedState>().clone();
+fn op_element_scroll_to(state: &OpState, #[string] nid_str: String, x: f64, y: f64, frame_id: u32) -> String {
+ let shared = frame_state(state, frame_id);
let nid = NodeId::new(nid_str.parse().unwrap_or(0));
let mut gs = shared.borrow_mut();
sample_live_document_animations(&mut gs);
@@ -7826,8 +7839,8 @@ fn op_element_scroll_to(state: &OpState, #[string] nid_str: String, x: f64, y: f
#[cfg(feature = "render")]
#[op2]
#[string]
-fn op_scroll_offset(state: &OpState) -> String {
- let shared = state.borrow::<SharedState>().clone();
+fn op_scroll_offset(state: &OpState, frame_id: u32) -> String {
+ let shared = frame_state(state, frame_id);
let mut gs = shared.borrow_mut();
sample_live_document_animations(&mut gs);
let requested = gs.scroll_offset;
@@ -7838,8 +7851,8 @@ fn op_scroll_offset(state: &OpState) -> String {
#[cfg(feature = "render")]
#[op2]
#[string]
-fn op_scroll_to(state: &OpState, x: f64, y: f64) -> String {
- let shared = state.borrow::<SharedState>().clone();
+fn op_scroll_to(state: &OpState, x: f64, y: f64, frame_id: u32) -> String {
+ let shared = frame_state(state, frame_id);
let mut gs = shared.borrow_mut();
sample_live_document_animations(&mut gs);
let (x, y) = clamp_scroll_offset_for_geometry(&mut gs, (x as f32, y as f32));
diff --git a/crates/obscura-js/src/runtime.rs b/crates/obscura-js/src/runtime.rs
index 7b4aa2a3..4c06e913 100644
--- a/crates/obscura-js/src/runtime.rs
+++ b/crates/obscura-js/src/runtime.rs
@@ -1491,16 +1491,7 @@ impl ObscuraJsRuntime {
return;
}
#[cfg(feature = "render")]
- {
- let mut state = self.state.borrow_mut();
- let viewport = (width as f32, height as f32);
- if state.viewport != viewport {
- state.viewport = viewport;
- state.prepared_render = None;
- state.pending_style_mutations.clear();
- state.resolved_scroll = None;
- }
- }
+ self.state.borrow_mut().set_viewport(width, height);
let _ = self.execute_runtime_script(
"<set-viewport>",
format!(
@@ -4976,6 +4967,48 @@ mod tests {
})()"#).unwrap(), serde_json::json!(["parent", "https://parent.example/"]));
}
+ #[cfg(feature = "render")]
+ #[test]
+ fn synchronous_iframe_geometry_uses_the_owning_document() {
+ let mut rt = setup_runtime(
+ "<html><head><style>body{margin:4px}#parent{width:45px;height:30px}</style></head><body><div id='parent'></div></body></html>");
+ assert_eq!(rt.evaluate(r#"(() => {
+ const iframe = document.createElement('iframe');
+ document.body.appendChild(iframe);
+ const d = iframe.contentDocument;
+ d.body.innerHTML = '<style>body{margin:8px}div{width:100px;height:20px}</style><div id="child"></div>';
+ const element = d.getElementById('child');
+ const range = d.createRange(); range.selectNode(element);
+ return [[...element.getClientRects()].map(r => [r.width, r.height, r.bottom]),
+ [...range.getClientRects()].map(r => r.bottom),
+ [element.clientWidth, element.clientHeight, element.offsetWidth, element.offsetHeight],
+ d.elementFromPoint(10, 10) === element,
+ document.getElementById('parent').getBoundingClientRect().width];
+ })()"#).unwrap(), serde_json::json!([
+ [[100, 20, 28]], [28], [100, 20, 100, 20], true, 45
+ ]));
+ }
+
+ #[cfg(feature = "render")]
+ #[test]
+ fn computed_style_on_a_foreign_frame_element_tracks_its_document() {
+ let mut rt = setup_runtime("<html><body></body></html>");
+ assert_eq!(rt.evaluate(r#"(() => {
+ const iframe = document.createElement('iframe');
+ document.body.appendChild(iframe);
+ const d = iframe.contentDocument;
+ d.body.innerHTML = '<style>#child{width:100px;height:20px;color:rgb(12,34,56)}</style><div id="child"></div>';
+ const element = d.getElementById('child');
+ const style = getComputedStyle(element);
+ const before = [style.width, style.color];
+ element.style.width = '120px';
+ element.style.color = 'rgb(78,90,12)';
+ return [before, [style.width, style.color], getComputedStyle(element).color];
+ })()"#).unwrap(), serde_json::json!([
+ ["100px", "rgb(12, 34, 56)"], ["120px", "rgb(78, 90, 12)"], "rgb(78, 90, 12)"
+ ]));
+ }
+
#[test]
fn borrowed_document_methods_keep_the_receiver_realm_after_prototype_remap() {
let mut rt = setup_runtime(
@@ -7870,6 +7903,30 @@ mod tests {
assert_eq!(result["item"], serde_json::json!([90, 25, "block"]));
}
+ #[cfg(feature = "render")]
+ #[tokio::test(flavor = "current_thread")]
+ async fn computed_style_refreshes_after_viewport_changes_without_dom_mutation() {
+ let mut rt = setup_runtime(r#"<style>
+ body { margin:0 }
+ #box { width:50vw; height:25vh; color:rgb(12,34,56) }
+ @media(max-width:250px) { #box { color:rgb(78,90,12) } }
+ </style><div id=box></div>"#);
+ rt.set_viewport(300.0, 80.0);
+ assert_eq!(rt.evaluate(r#"(() => {
+ globalThis.savedStyle = getComputedStyle(document.getElementById('box'));
+ return [savedStyle.width, savedStyle.height, savedStyle.color];
+ })()"#).unwrap(), serde_json::json!(["150px", "20px", "rgb(12, 34, 56)"]));
+ rt.set_viewport(200.0, 120.0);
+ assert_eq!(rt.evaluate(r#"(() => {
+ const fresh = getComputedStyle(document.getElementById('box'));
+ return [[savedStyle.width, savedStyle.height, savedStyle.color],
+ [fresh.width, fresh.height, fresh.color]];
+ })()"#).unwrap(), serde_json::json!([
+ ["100px", "30px", "rgb(78, 90, 12)"],
+ ["100px", "30px", "rgb(78, 90, 12)"]
+ ]));
+ }
+
#[cfg(feature = "render")]
#[tokio::test(flavor = "current_thread")]
async fn computed_style_non_geometric_reads_defer_layout_without_losing_damage() {
@@ -12822,10 +12879,10 @@ mod tests {
const nativeBulk = __obscura_test_ops.op_resize_observer_measurements;
const nativeGeometry = __obscura_test_ops.op_layout_geometry;
const nativeComputedStyle = __obscura_test_ops.op_computed_style;
- __obscura_test_ops.op_resize_observer_measurements = input => {
+ __obscura_test_ops.op_resize_observer_measurements = (input, frameId) => {
__resizeBulkCalls++;
__resizeBulkSizes.push(JSON.parse(input).length);
- return nativeBulk(input);
+ return nativeBulk(input, frameId);
};
__obscura_test_ops.op_layout_geometry = (...args) => {
__resizeLegacyGeometryCalls++;
@@ -13190,10 +13247,10 @@ mod tests {
const nativeBulk = __obscura_test_ops.op_intersection_observer_measurements;
const nativeGeometry = __obscura_test_ops.op_layout_geometry;
const nativeComputedStyle = __obscura_test_ops.op_computed_style;
- __obscura_test_ops.op_intersection_observer_measurements = input => {
+ __obscura_test_ops.op_intersection_observer_measurements = (input, frameId) => {
__intersectionBulkCalls++;
__intersectionBulkSizes.push(JSON.parse(input).length);
- return nativeBulk(input);
+ return nativeBulk(input, frameId);
};
__obscura_test_ops.op_layout_geometry = (...args) => {
__intersectionLegacyGeometryCalls++;