diff --git a/moli-renderer-v8/src/observer_runtime/mod.rs b/moli-renderer-v8/src/observer_runtime/mod.rs index 3dcb34c64d5..56dcf9bc18e 100644 --- a/moli-renderer-v8/src/observer_runtime/mod.rs +++ b/moli-renderer-v8/src/observer_runtime/mod.rs @@ -722,6 +722,8 @@ fn invoke_mutation_deliveries<'s>( if !delivery.callback.is_current(scope) { continue; } + // Convert callback arguments in the callback function's Realm, which + // can differ from the observer's construction Realm. let callback_context = delivery.callback.relevant_context(scope); let records_array = { let scope = &mut v8::ContextScope::new(scope, callback_context); diff --git a/moli-renderer-v8/tests/fixtures/mutation-record-attributes.js b/moli-renderer-v8/tests/fixtures/mutation-record-attributes.js index d214e0026e7..159535bef8f 100644 --- a/moli-renderer-v8/tests/fixtures/mutation-record-attributes.js +++ b/moli-renderer-v8/tests/fixtures/mutation-record-attributes.js @@ -42,9 +42,9 @@ function produce(owner, doc) { const host = doc.createElement('item'); const left = doc.createTextNode('left'), right = doc.createTextNode('right'); - const text = doc.createTextNode('old text\u00e9'), middle = doc.createElement('middle'); + const text = doc.createTextNode('old text\udfff'), middle = doc.createElement('middle'); host.append(left, right, text); - host.setAttributeNS('urn:record', 'p:keep', 'old attr\u{1D306}'); + host.setAttributeNS('urn:record', 'p:keep', 'old attr\ud800'); const observer = new owner.MutationObserver(() => {}); observer.observe(host, {attributes: true, attributeOldValue: true, characterData: true, characterDataOldValue: true, childList: true, subtree: true}); @@ -58,8 +58,8 @@ attributeName: null, attributeNamespace: null, oldValue: null}; const expected = [ {...empty, type: 'attributes', target: host, attributeName: 'keep', - attributeNamespace: 'urn:record', oldValue: 'old attr\u{1D306}'}, - {...empty, type: 'characterData', target: text, oldValue: 'old text\u00e9'}, + attributeNamespace: 'urn:record', oldValue: 'old attr\ud800'}, + {...empty, type: 'characterData', target: text, oldValue: 'old text\udfff'}, {...empty, type: 'childList', target: host, addedNodes: [middle], previousSibling: left, nextSibling: right}, ]; return {records, expected, host, text, middle};