inlineImages: Setting of image.crossOrigin is not always necessary (#1468)

Setting of the `crossorigin` attribute is not necessary for same-origin images, and causes an immediate image reload (albeit from cache) necessitating the use of a load event listener which subsequently mutates the snapshot.  This change allows us to  avoid the mutation of the snapshot for the same-origin case.

* Modify inlineImages test to remove delay and show that we can inline images without mutation

* Add an explicit test for when the `image.crossOrigin = 'anonymous';` method is necessary.  Uses a combination of about:blank and our test server to simulate a cross-origin context

* Other test changes: there were some spurious rrweb mutations being generated by the addition of the crossorigin attribute that are now elimnated from the rrweb/__snapshots__/integration.test.ts.snap after this PR - this is good
This commit is contained in:
Eoghan Murray
2026-04-01 12:00:00 +08:00
committed by GitHub
parent 083da07212
commit 1b79b5b6c2
8 changed files with 95 additions and 117 deletions

View File

@@ -12777,40 +12777,6 @@ exports[`record integration tests should record images inside iframe with blob u
}
]
}
},
{
\\"type\\": 3,
\\"data\\": {
\\"source\\": 0,
\\"texts\\": [],
\\"attributes\\": [
{
\\"id\\": 41,
\\"attributes\\": {
\\"crossorigin\\": \\"anonymous\\"
}
}
],
\\"removes\\": [],
\\"adds\\": []
}
},
{
\\"type\\": 3,
\\"data\\": {
\\"source\\": 0,
\\"texts\\": [],
\\"attributes\\": [
{
\\"id\\": 41,
\\"attributes\\": {
\\"crossorigin\\": null
}
}
],
\\"removes\\": [],
\\"adds\\": []
}
}
]"
`;
@@ -13245,40 +13211,6 @@ exports[`record integration tests should record images inside iframe with blob u
}
]
}
},
{
\\"type\\": 3,
\\"data\\": {
\\"source\\": 0,
\\"texts\\": [],
\\"attributes\\": [
{
\\"id\\": 47,
\\"attributes\\": {
\\"crossorigin\\": \\"anonymous\\"
}
}
],
\\"removes\\": [],
\\"adds\\": []
}
},
{
\\"type\\": 3,
\\"data\\": {
\\"source\\": 0,
\\"texts\\": [],
\\"attributes\\": [
{
\\"id\\": 47,
\\"attributes\\": {
\\"crossorigin\\": null
}
}
],
\\"removes\\": [],
\\"adds\\": []
}
}
]"
`;
@@ -13486,40 +13418,6 @@ exports[`record integration tests should record images with blob url 1`] = `
}
]
}
},
{
\\"type\\": 3,
\\"data\\": {
\\"source\\": 0,
\\"texts\\": [],
\\"attributes\\": [
{
\\"id\\": 24,
\\"attributes\\": {
\\"crossorigin\\": \\"anonymous\\"
}
}
],
\\"removes\\": [],
\\"adds\\": []
}
},
{
\\"type\\": 3,
\\"data\\": {
\\"source\\": 0,
\\"texts\\": [],
\\"attributes\\": [
{
\\"id\\": 24,
\\"attributes\\": {
\\"crossorigin\\": null
}
}
],
\\"removes\\": [],
\\"adds\\": []
}
}
]"
`;