moved rrweb-snapshot into packages/rrweb-snapshot
This commit is contained in:
838
packages/rrweb-snapshot/test/__snapshots__/integration.ts.snap
Normal file
838
packages/rrweb-snapshot/test/__snapshots__/integration.ts.snap
Normal file
@@ -0,0 +1,838 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`[html file]: about-mozilla.html 1`] = `
|
||||
"<!DOCTYPE html><html xmlns=\\"http://www.w3.org/1999/xhtml\\"><head>
|
||||
<title>The Book of Mozilla, 11:9</title>
|
||||
<style type=\\"text/css\\">
|
||||
html {
|
||||
background: maroon;
|
||||
color: white;
|
||||
font-style: italic;
|
||||
} #moztext {
|
||||
margin-top: 15%;
|
||||
font-size: 1.1em;
|
||||
font-family: serif;
|
||||
text-align: center;
|
||||
line-height: 1.5;
|
||||
} #from {
|
||||
font-size: 1.95em;
|
||||
font-family: serif;
|
||||
text-align: right;
|
||||
} em {
|
||||
font-size: 1.3em;
|
||||
line-height: 0;
|
||||
} a {
|
||||
text-decoration: none;
|
||||
color: white;
|
||||
}
|
||||
</style>
|
||||
</head><body> <p id=\\"moztext\\">
|
||||
Mammon slept. And the <em>beast reborn</em> spread over the earth and its numbers
|
||||
grew legion. And they proclaimed the times and <em>sacrificed</em> crops unto the
|
||||
fire, with the <em>cunning of foxes</em>. And they built a new world in their own
|
||||
image as promised by the <em><a href=\\"http://www.mozilla.org/about/mozilla-manifesto.html\\">
|
||||
sacred words</a></em>, and <em><a href=\\"http://wiki.mozilla.org/About:mozilla\\">spoke
|
||||
</a></em> of the beast with their children. Mammon awoke, and lo! it was
|
||||
<em>naught</em> but a follower.
|
||||
</p> <p id=\\"from\\">
|
||||
from <strong>The Book of Mozilla,</strong> 11:9<br /><small>(10th Edition)</small>
|
||||
</p></body></html>"
|
||||
`;
|
||||
|
||||
exports[`[html file]: basic.html 1`] = `
|
||||
"<!DOCTYPE html><html xmlns=\\"http://www.w3.org/1999/xhtml\\" lang=\\"en\\"><head>
|
||||
<meta charset=\\"UTF-8\\" />
|
||||
<meta name=\\"viewport\\" content=\\"width=device-width, initial-scale=1.0\\" />
|
||||
<meta http-equiv=\\"X-UA-Compatible\\" content=\\"ie=edge\\" />
|
||||
<title>Document</title>
|
||||
</head><body>
|
||||
<h1>Title</h1></body></html>"
|
||||
`;
|
||||
|
||||
exports[`[html file]: block-element.html 1`] = `
|
||||
"<!DOCTYPE html><html xmlns=\\"http://www.w3.org/1999/xhtml\\" lang=\\"en\\"><head>
|
||||
<meta charset=\\"UTF-8\\" />
|
||||
<meta name=\\"viewport\\" content=\\"width=device-width, initial-scale=1.0\\" />
|
||||
<meta http-equiv=\\"X-UA-Compatible\\" content=\\"ie=edge\\" />
|
||||
<title>Document</title>
|
||||
<style>
|
||||
.big {
|
||||
width: 50px;
|
||||
height: 50px;
|
||||
}
|
||||
.small {
|
||||
width: 50px;
|
||||
height: 100px;
|
||||
float: left;
|
||||
}
|
||||
</style>
|
||||
</head> <body>
|
||||
<div class=\\"rr-block big\\" style=\\"width: 50px; height: 50px;\\"></div>
|
||||
<div>record 2</div>
|
||||
<div class=\\"rr-block small\\" style=\\"width: 50px; height: 100px;\\"></div>
|
||||
<div class=\\"rr-block\\" style=\\"width: 100px; height: 200px;\\"></div>
|
||||
</body></html>"
|
||||
`;
|
||||
|
||||
exports[`[html file]: cors-style-sheet.html 1`] = `
|
||||
"<!DOCTYPE html><html xmlns=\\"http://www.w3.org/1999/xhtml\\" lang=\\"en\\"><head>
|
||||
<meta charset=\\"UTF-8\\" />
|
||||
<meta name=\\"viewport\\" content=\\"width=device-width, initial-scale=1.0\\" />
|
||||
<meta http-equiv=\\"X-UA-Compatible\\" content=\\"ie=edge\\" />
|
||||
<title>with style sheet</title>
|
||||
<link rel=\\"stylesheet\\" href=\\"https://cdn.jsdelivr.net/npm/pure@2.85.0/index.css\\" />
|
||||
<link rel=\\"stylesheet\\" href=\\"\\" />
|
||||
</head>
|
||||
<body></body></html>"
|
||||
`;
|
||||
|
||||
exports[`[html file]: dynamic-stylesheet.html 1`] = `
|
||||
"<!DOCTYPE html><html xmlns=\\"http://www.w3.org/1999/xhtml\\" lang=\\"en\\"><head>
|
||||
<meta charset=\\"UTF-8\\" />
|
||||
<meta name=\\"viewport\\" content=\\"width=device-width, initial-scale=1.0\\" />
|
||||
<meta http-equiv=\\"X-UA-Compatible\\" content=\\"ie=edge\\" />
|
||||
<title>dynamic stylesheet</title>
|
||||
<style>body { margin: 0px; }p { background: lightpink; }</style>
|
||||
<noscript>SCRIPT_PLACEHOLDER</noscript>
|
||||
</head>
|
||||
<body>
|
||||
<p>p tag</p>
|
||||
</body></html>"
|
||||
`;
|
||||
|
||||
exports[`[html file]: form-fields.html 1`] = `
|
||||
"<!DOCTYPE html><html xmlns=\\"http://www.w3.org/1999/xhtml\\" lang=\\"en\\"><head>
|
||||
<meta charset=\\"UTF-8\\" />
|
||||
<meta name=\\"viewport\\" content=\\"width=device-width, initial-scale=1.0\\" />
|
||||
<meta http-equiv=\\"X-UA-Compatible\\" content=\\"ie=edge\\" />
|
||||
<title>form fields</title>
|
||||
</head> <body>
|
||||
<form>
|
||||
<label for=\\"text\\">
|
||||
<input type=\\"text\\" value=\\"1\\" />
|
||||
</label>
|
||||
<label for=\\"radio\\">
|
||||
<input type=\\"radio\\" checked=\\"\\" />
|
||||
</label>
|
||||
<label for=\\"checkbox\\">
|
||||
<input type=\\"checkbox\\" checked=\\"\\" />
|
||||
</label>
|
||||
<label for=\\"textarea\\">
|
||||
<textarea name=\\"\\" id=\\"\\" cols=\\"30\\" rows=\\"10\\">1234</textarea>
|
||||
</label>
|
||||
<label for=\\"select\\">
|
||||
<select name=\\"\\" id=\\"\\" value=\\"2\\">
|
||||
<option value=\\"1\\">1</option>
|
||||
<option value=\\"2\\" selected=\\"\\">2</option>
|
||||
</select>
|
||||
</label>
|
||||
<label>
|
||||
<input name=\\"tagName\\" />
|
||||
</label>
|
||||
</form>
|
||||
|
||||
<noscript>SCRIPT_PLACEHOLDER</noscript></body></html>"
|
||||
`;
|
||||
|
||||
exports[`[html file]: hover.html 1`] = `
|
||||
"<!DOCTYPE html><html xmlns=\\"http://www.w3.org/1999/xhtml\\" lang=\\"en\\"><head>
|
||||
<meta charset=\\"UTF-8\\" />
|
||||
<meta name=\\"viewport\\" content=\\"width=device-width, initial-scale=1.0\\" />
|
||||
<meta http-equiv=\\"X-UA-Compatible\\" content=\\"ie=edge\\" />
|
||||
<title>hover selector</title>
|
||||
<style> div:hover, div.\\\\:hover {
|
||||
background: orange;
|
||||
} div:hover::after, div.\\\\:hover::after {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 100%;
|
||||
content: 'dropdown';
|
||||
width: 100px;
|
||||
height: 200px;
|
||||
background: lightblue;
|
||||
}
|
||||
</style>
|
||||
</head><body>
|
||||
<div>hover me</div>
|
||||
</body></html>"
|
||||
`;
|
||||
|
||||
exports[`[html file]: iframe.html 1`] = `
|
||||
"<!DOCTYPE html><html xmlns=\\"http://www.w3.org/1999/xhtml\\" lang=\\"en\\"><head>
|
||||
<meta charset=\\"UTF-8\\" />
|
||||
<meta name=\\"viewport\\" content=\\"width=device-width, initial-scale=1.0\\" />
|
||||
<meta http-equiv=\\"X-UA-Compatible\\" content=\\"ie=edge\\" />
|
||||
<title>iframe</title>
|
||||
</head>
|
||||
<body>
|
||||
<iframe width=\\"100\\" height=\\"50\\"></iframe>
|
||||
</body></html>"
|
||||
`;
|
||||
|
||||
exports[`[html file]: iframe-inner.html 1`] = `
|
||||
"<html xmlns=\\"http://www.w3.org/1999/xhtml\\"><head></head><body><button>inner iframe button</button>
|
||||
</body></html>"
|
||||
`;
|
||||
|
||||
exports[`[html file]: invalid-attribute.html 1`] = `
|
||||
"<html xmlns=\\"http://www.w3.org/1999/xhtml\\" foo=\\"bar\\"><head></head><body>
|
||||
</body></html>"
|
||||
`;
|
||||
|
||||
exports[`[html file]: invalid-doctype.html 1`] = `
|
||||
"<!DOCTYPE html><html xmlns=\\"http://www.w3.org/1999/xhtml\\" lang=\\"en\\"><head>
|
||||
<meta charset=\\"UTF-8\\" />
|
||||
<meta name=\\"viewport\\" content=\\"width=device-width, initial-scale=1.0\\" />
|
||||
<title>Invalid Doctype</title>
|
||||
</head>
|
||||
<body></body></html>"
|
||||
`;
|
||||
|
||||
exports[`[html file]: invalid-tagname.html 1`] = `
|
||||
"<!DOCTYPE html><html xmlns=\\"http://www.w3.org/1999/xhtml\\" lang=\\"en\\"><head>
|
||||
<meta charset=\\"UTF-8\\" />
|
||||
<meta name=\\"viewport\\" content=\\"width=device-width, initial-scale=1.0\\" />
|
||||
<meta http-equiv=\\"X-UA-Compatible\\" content=\\"ie=edge\\" />
|
||||
<title>Document</title>
|
||||
</head>
|
||||
<body>
|
||||
<div>Hello</div>
|
||||
<div>Hello</div>
|
||||
<div></div>
|
||||
</body></html>"
|
||||
`;
|
||||
|
||||
exports[`[html file]: mask-text.html 1`] = `
|
||||
"<!DOCTYPE html><html xmlns=\\"http://www.w3.org/1999/xhtml\\" lang=\\"en\\"><head>
|
||||
<meta charset=\\"UTF-8\\" />
|
||||
<meta name=\\"viewport\\" content=\\"width=device-width, initial-scale=1.0\\" />
|
||||
<meta http-equiv=\\"X-UA-Compatible\\" content=\\"ie=edge\\" />
|
||||
<title>Document</title>
|
||||
</head> <body>
|
||||
<p class=\\"rr-mask\\">**** *</p>
|
||||
<div class=\\"rr-mask\\">
|
||||
<span>**** *</span>
|
||||
</div>
|
||||
<div class=\\"rr-mask\\">**** *</div>
|
||||
</body></html>"
|
||||
`;
|
||||
|
||||
exports[`[html file]: picture.html 1`] = `
|
||||
"<html xmlns=\\"http://www.w3.org/1999/xhtml\\"><head></head><body>
|
||||
<picture>
|
||||
<source type=\\"image/webp\\" srcset=\\"http://localhost:3030/assets/img/characters/robot.webp\\" />
|
||||
<img src=\\"http://localhost:3030/assets/img/characters/robot.png\\" />
|
||||
</picture>
|
||||
</body></html>"
|
||||
`;
|
||||
|
||||
exports[`[html file]: preload.html 1`] = `
|
||||
"<!DOCTYPE html><html xmlns=\\"http://www.w3.org/1999/xhtml\\" lang=\\"en\\"><head>
|
||||
<meta charset=\\"UTF-8\\" />
|
||||
<meta name=\\"viewport\\" content=\\"width=device-width, initial-scale=1.0\\" />
|
||||
<title>Document</title>
|
||||
<link />
|
||||
<link />
|
||||
</head>
|
||||
<body></body></html>"
|
||||
`;
|
||||
|
||||
exports[`[html file]: shadow-dom.html 1`] = `
|
||||
"<!DOCTYPE html><html xmlns=\\"http://www.w3.org/1999/xhtml\\" lang=\\"en\\"><head>
|
||||
<meta charset=\\"UTF-8\\" />
|
||||
<meta name=\\"viewport\\" content=\\"width=device-width, initial-scale=1.0\\" />
|
||||
<title>shadow DOM</title>
|
||||
</head>
|
||||
<body>
|
||||
<fancy-tabs background=\\"\\" role=\\"tablist\\" selected=\\"1\\">
|
||||
<button slot=\\"title\\" role=\\"tab\\" tabindex=\\"-1\\" aria-selected=\\"false\\">Tab 1</button>
|
||||
<button slot=\\"title\\" selected=\\"\\" role=\\"tab\\" tabindex=\\"0\\" aria-selected=\\"true\\">Tab 2</button>
|
||||
<button slot=\\"title\\" role=\\"tab\\" tabindex=\\"-1\\" aria-selected=\\"false\\">Tab 3</button>
|
||||
<section role=\\"tabpanel\\" tabindex=\\"0\\" aria-hidden=\\"true\\">content panel 1</section>
|
||||
<section role=\\"tabpanel\\" tabindex=\\"0\\" aria-hidden=\\"false\\">content panel 2</section>
|
||||
<section role=\\"tabpanel\\" tabindex=\\"0\\" aria-hidden=\\"true\\">content panel 3</section>
|
||||
</fancy-tabs>
|
||||
<noscript>SCRIPT_PLACEHOLDER</noscript>
|
||||
</body></html>"
|
||||
`;
|
||||
|
||||
exports[`[html file]: video.html 1`] = `
|
||||
"<!DOCTYPE html><html xmlns=\\"http://www.w3.org/1999/xhtml\\" lang=\\"en\\"><head>
|
||||
<meta charset=\\"UTF-8\\" />
|
||||
<meta name=\\"viewport\\" content=\\"width=device-width, initial-scale=1.0\\" />
|
||||
<meta http-equiv=\\"X-UA-Compatible\\" content=\\"ie=edge\\" />
|
||||
<title>video</title>
|
||||
</head>
|
||||
<body>
|
||||
<video controls=\\"\\">
|
||||
<source src=\\"http://techslides.com/demos/sample-videos/small.webm\\" type=\\"video/webm\\" /> <source src=\\"http://techslides.com/demos/sample-videos/small.ogv\\" type=\\"video/ogg\\" />
|
||||
<source src=\\"http://techslides.com/demos/sample-videos/small.mp4\\" type=\\"video/mp4\\" /> <source src=\\"http://techslides.com/demos/sample-videos/small.3gp\\" type=\\"video/3gp\\" />
|
||||
</video>
|
||||
</body></html>"
|
||||
`;
|
||||
|
||||
exports[`[html file]: with-relative-res.html 1`] = `
|
||||
"<!DOCTYPE html><html xmlns=\\"http://www.w3.org/1999/xhtml\\" lang=\\"en\\"><head>
|
||||
<meta charset=\\"UTF-8\\" />
|
||||
<meta name=\\"viewport\\" content=\\"width=device-width, initial-scale=1.0\\" />
|
||||
<meta http-equiv=\\"X-UA-Compatible\\" content=\\"ie=edge\\" />
|
||||
<title>Document</title>
|
||||
</head>
|
||||
<body>
|
||||
<a href=\\"http://localhost:3030/basic.html\\"></a>
|
||||
<div>Hello</div>
|
||||
<alt34>Hello</alt34>
|
||||
<div>Hello</div>
|
||||
<div></div>
|
||||
<img src=\\"http://localhost:3030/a.jpg\\" alt=\\"\\" srcset=\\"\\" />
|
||||
<img src=\\"http://localhost:3030/a.jpg\\" alt=\\"\\" srcset=\\"http://localhost:3030/a.jpg\\" />
|
||||
<img src=\\"http://localhost:3030/a.jpg\\" alt=\\"\\" srcset=\\"http://exmple.com/a.jpg\\" />
|
||||
<img src=\\"http://localhost:3030/a.jpg\\" alt=\\"\\" srcset=\\"http://localhost:3030/a.jpg 3x, http://localhost:3030/a.jpg 45x, http://localhost:3030/b.png\\" />
|
||||
<img src=\\"http://localhost:3030/a.jpg\\" alt=\\"\\" srcset=\\"http://localhost:3030/300,400/a.jpg 300w, http://localhost:3030/b.png\\" /></body></html>"
|
||||
`;
|
||||
|
||||
exports[`[html file]: with-script.html 1`] = `
|
||||
"<!DOCTYPE html><html xmlns=\\"http://www.w3.org/1999/xhtml\\" lang=\\"en\\"><head>
|
||||
<meta charset=\\"UTF-8\\" />
|
||||
<meta name=\\"viewport\\" content=\\"width=device-width, initial-scale=1.0\\" />
|
||||
<meta http-equiv=\\"X-UA-Compatible\\" content=\\"ie=edge\\" />
|
||||
<title>with script</title>
|
||||
</head><body>
|
||||
<noscript src=\\"http://localhost:3030/js/a.js\\"></noscript>
|
||||
<noscript>SCRIPT_PLACEHOLDER</noscript></body></html>"
|
||||
`;
|
||||
|
||||
exports[`[html file]: with-style-sheet.html 1`] = `
|
||||
"<!DOCTYPE html><html xmlns=\\"http://www.w3.org/1999/xhtml\\" lang=\\"en\\"><head>
|
||||
<meta charset=\\"UTF-8\\" />
|
||||
<meta name=\\"viewport\\" content=\\"width=device-width, initial-scale=1.0\\" />
|
||||
<meta http-equiv=\\"X-UA-Compatible\\" content=\\"ie=edge\\" />
|
||||
<title>with style sheet</title>
|
||||
<style>body { margin: 0px; background: url(\\"http://localhost:3030/a.jpg\\"); border-image: url(\\"data:image/svg+xml;utf8,<svg xmlns=\\\\\\"http://www.w3.org/2000/svg\\\\\\" x=\\\\\\"0px\\\\\\" y=\\\\\\"0px\\\\\\" viewBox=\\\\\\"0 0 256 256\\\\\\"><g><g><polygon points=\\\\\\"79.093,0 48.907,30.187 146.72,128 48.907,225.813 79.093,256 207.093,128\\\\\\"/></g></g></svg>\\") 100% / 1 / 0 stretch; }p { color: red; background: url(\\"http://localhost:3030/css/b.jpg\\"); }body > p { color: yellow; }</style>
|
||||
</head><body>
|
||||
</body></html>"
|
||||
`;
|
||||
|
||||
exports[`[html file]: with-style-sheet-with-import.html 1`] = `
|
||||
"<!DOCTYPE html><html xmlns=\\"http://www.w3.org/1999/xhtml\\" lang=\\"en\\"><head>
|
||||
<meta charset=\\"UTF-8\\" />
|
||||
<meta name=\\"viewport\\" content=\\"width=device-width, initial-scale=1.0\\" />
|
||||
<meta http-equiv=\\"X-UA-Compatible\\" content=\\"ie=edge\\" />
|
||||
<title>with style sheet with import</title>
|
||||
<style>body { margin: 0px; background: url(\\"http://localhost:3030/a.jpg\\"); border-image: url(\\"data:image/svg+xml;utf8,<svg xmlns=\\\\\\"http://www.w3.org/2000/svg\\\\\\" x=\\\\\\"0px\\\\\\" y=\\\\\\"0px\\\\\\" viewBox=\\\\\\"0 0 256 256\\\\\\"><g><g><polygon points=\\\\\\"79.093,0 48.907,30.187 146.72,128 48.907,225.813 79.093,256 207.093,128\\\\\\"/></g></g></svg>\\") 100% / 1 / 0 stretch; }p { color: red; background: url(\\"http://localhost:3030/css/b.jpg\\"); }body > p { color: yellow; }</style>
|
||||
</head><body>
|
||||
</body></html>"
|
||||
`;
|
||||
|
||||
exports[`iframe integration tests 1`] = `
|
||||
"{
|
||||
\\"type\\": 0,
|
||||
\\"childNodes\\": [
|
||||
{
|
||||
\\"type\\": 1,
|
||||
\\"name\\": \\"html\\",
|
||||
\\"publicId\\": \\"\\",
|
||||
\\"systemId\\": \\"\\",
|
||||
\\"id\\": 2
|
||||
},
|
||||
{
|
||||
\\"type\\": 2,
|
||||
\\"tagName\\": \\"html\\",
|
||||
\\"attributes\\": {
|
||||
\\"lang\\": \\"en\\"
|
||||
},
|
||||
\\"childNodes\\": [
|
||||
{
|
||||
\\"type\\": 2,
|
||||
\\"tagName\\": \\"head\\",
|
||||
\\"attributes\\": {},
|
||||
\\"childNodes\\": [
|
||||
{
|
||||
\\"type\\": 3,
|
||||
\\"textContent\\": \\"\\\\n \\",
|
||||
\\"id\\": 5
|
||||
},
|
||||
{
|
||||
\\"type\\": 2,
|
||||
\\"tagName\\": \\"meta\\",
|
||||
\\"attributes\\": {
|
||||
\\"charset\\": \\"UTF-8\\"
|
||||
},
|
||||
\\"childNodes\\": [],
|
||||
\\"id\\": 6
|
||||
},
|
||||
{
|
||||
\\"type\\": 3,
|
||||
\\"textContent\\": \\"\\\\n \\",
|
||||
\\"id\\": 7
|
||||
},
|
||||
{
|
||||
\\"type\\": 2,
|
||||
\\"tagName\\": \\"meta\\",
|
||||
\\"attributes\\": {
|
||||
\\"name\\": \\"viewport\\",
|
||||
\\"content\\": \\"width=device-width, initial-scale=1.0\\"
|
||||
},
|
||||
\\"childNodes\\": [],
|
||||
\\"id\\": 8
|
||||
},
|
||||
{
|
||||
\\"type\\": 3,
|
||||
\\"textContent\\": \\"\\\\n \\",
|
||||
\\"id\\": 9
|
||||
},
|
||||
{
|
||||
\\"type\\": 2,
|
||||
\\"tagName\\": \\"title\\",
|
||||
\\"attributes\\": {},
|
||||
\\"childNodes\\": [
|
||||
{
|
||||
\\"type\\": 3,
|
||||
\\"textContent\\": \\"Main\\",
|
||||
\\"id\\": 11
|
||||
}
|
||||
],
|
||||
\\"id\\": 10
|
||||
},
|
||||
{
|
||||
\\"type\\": 3,
|
||||
\\"textContent\\": \\"\\\\n \\",
|
||||
\\"id\\": 12
|
||||
}
|
||||
],
|
||||
\\"id\\": 4
|
||||
},
|
||||
{
|
||||
\\"type\\": 3,
|
||||
\\"textContent\\": \\"\\\\n \\",
|
||||
\\"id\\": 13
|
||||
},
|
||||
{
|
||||
\\"type\\": 2,
|
||||
\\"tagName\\": \\"body\\",
|
||||
\\"attributes\\": {},
|
||||
\\"childNodes\\": [
|
||||
{
|
||||
\\"type\\": 3,
|
||||
\\"textContent\\": \\"\\\\n \\",
|
||||
\\"id\\": 15
|
||||
},
|
||||
{
|
||||
\\"type\\": 2,
|
||||
\\"tagName\\": \\"iframe\\",
|
||||
\\"attributes\\": {
|
||||
\\"id\\": \\"one\\"
|
||||
},
|
||||
\\"childNodes\\": [],
|
||||
\\"id\\": 16
|
||||
},
|
||||
{
|
||||
\\"type\\": 3,
|
||||
\\"textContent\\": \\"\\\\n \\",
|
||||
\\"id\\": 17
|
||||
},
|
||||
{
|
||||
\\"type\\": 2,
|
||||
\\"tagName\\": \\"iframe\\",
|
||||
\\"attributes\\": {
|
||||
\\"id\\": \\"two\\"
|
||||
},
|
||||
\\"childNodes\\": [],
|
||||
\\"id\\": 18
|
||||
},
|
||||
{
|
||||
\\"type\\": 3,
|
||||
\\"textContent\\": \\"\\\\n \\\\n\\\\n\\",
|
||||
\\"id\\": 19
|
||||
}
|
||||
],
|
||||
\\"id\\": 14
|
||||
}
|
||||
],
|
||||
\\"id\\": 3
|
||||
}
|
||||
],
|
||||
\\"id\\": 1
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`shadown DOM integration tests 1`] = `
|
||||
"{
|
||||
\\"type\\": 0,
|
||||
\\"childNodes\\": [
|
||||
{
|
||||
\\"type\\": 1,
|
||||
\\"name\\": \\"html\\",
|
||||
\\"publicId\\": \\"\\",
|
||||
\\"systemId\\": \\"\\",
|
||||
\\"id\\": 2
|
||||
},
|
||||
{
|
||||
\\"type\\": 2,
|
||||
\\"tagName\\": \\"html\\",
|
||||
\\"attributes\\": {
|
||||
\\"lang\\": \\"en\\"
|
||||
},
|
||||
\\"childNodes\\": [
|
||||
{
|
||||
\\"type\\": 2,
|
||||
\\"tagName\\": \\"head\\",
|
||||
\\"attributes\\": {},
|
||||
\\"childNodes\\": [
|
||||
{
|
||||
\\"type\\": 3,
|
||||
\\"textContent\\": \\"\\\\n \\",
|
||||
\\"id\\": 5
|
||||
},
|
||||
{
|
||||
\\"type\\": 2,
|
||||
\\"tagName\\": \\"meta\\",
|
||||
\\"attributes\\": {
|
||||
\\"charset\\": \\"UTF-8\\"
|
||||
},
|
||||
\\"childNodes\\": [],
|
||||
\\"id\\": 6
|
||||
},
|
||||
{
|
||||
\\"type\\": 3,
|
||||
\\"textContent\\": \\"\\\\n \\",
|
||||
\\"id\\": 7
|
||||
},
|
||||
{
|
||||
\\"type\\": 2,
|
||||
\\"tagName\\": \\"meta\\",
|
||||
\\"attributes\\": {
|
||||
\\"name\\": \\"viewport\\",
|
||||
\\"content\\": \\"width=device-width, initial-scale=1.0\\"
|
||||
},
|
||||
\\"childNodes\\": [],
|
||||
\\"id\\": 8
|
||||
},
|
||||
{
|
||||
\\"type\\": 3,
|
||||
\\"textContent\\": \\"\\\\n \\",
|
||||
\\"id\\": 9
|
||||
},
|
||||
{
|
||||
\\"type\\": 2,
|
||||
\\"tagName\\": \\"title\\",
|
||||
\\"attributes\\": {},
|
||||
\\"childNodes\\": [
|
||||
{
|
||||
\\"type\\": 3,
|
||||
\\"textContent\\": \\"shadow DOM\\",
|
||||
\\"id\\": 11
|
||||
}
|
||||
],
|
||||
\\"id\\": 10
|
||||
},
|
||||
{
|
||||
\\"type\\": 3,
|
||||
\\"textContent\\": \\"\\\\n \\",
|
||||
\\"id\\": 12
|
||||
}
|
||||
],
|
||||
\\"id\\": 4
|
||||
},
|
||||
{
|
||||
\\"type\\": 3,
|
||||
\\"textContent\\": \\"\\\\n \\",
|
||||
\\"id\\": 13
|
||||
},
|
||||
{
|
||||
\\"type\\": 2,
|
||||
\\"tagName\\": \\"body\\",
|
||||
\\"attributes\\": {},
|
||||
\\"childNodes\\": [
|
||||
{
|
||||
\\"type\\": 3,
|
||||
\\"textContent\\": \\"\\\\n \\",
|
||||
\\"id\\": 15
|
||||
},
|
||||
{
|
||||
\\"type\\": 2,
|
||||
\\"tagName\\": \\"fancy-tabs\\",
|
||||
\\"attributes\\": {
|
||||
\\"background\\": \\"\\",
|
||||
\\"role\\": \\"tablist\\",
|
||||
\\"selected\\": \\"1\\"
|
||||
},
|
||||
\\"childNodes\\": [
|
||||
{
|
||||
\\"type\\": 3,
|
||||
\\"textContent\\": \\"\\\\n \\",
|
||||
\\"id\\": 17
|
||||
},
|
||||
{
|
||||
\\"type\\": 2,
|
||||
\\"tagName\\": \\"button\\",
|
||||
\\"attributes\\": {
|
||||
\\"slot\\": \\"title\\",
|
||||
\\"role\\": \\"tab\\",
|
||||
\\"tabindex\\": \\"-1\\",
|
||||
\\"aria-selected\\": \\"false\\"
|
||||
},
|
||||
\\"childNodes\\": [
|
||||
{
|
||||
\\"type\\": 3,
|
||||
\\"textContent\\": \\"Tab 1\\",
|
||||
\\"id\\": 19
|
||||
}
|
||||
],
|
||||
\\"id\\": 18
|
||||
},
|
||||
{
|
||||
\\"type\\": 3,
|
||||
\\"textContent\\": \\"\\\\n \\",
|
||||
\\"id\\": 20
|
||||
},
|
||||
{
|
||||
\\"type\\": 2,
|
||||
\\"tagName\\": \\"button\\",
|
||||
\\"attributes\\": {
|
||||
\\"slot\\": \\"title\\",
|
||||
\\"selected\\": \\"\\",
|
||||
\\"role\\": \\"tab\\",
|
||||
\\"tabindex\\": \\"0\\",
|
||||
\\"aria-selected\\": \\"true\\"
|
||||
},
|
||||
\\"childNodes\\": [
|
||||
{
|
||||
\\"type\\": 3,
|
||||
\\"textContent\\": \\"Tab 2\\",
|
||||
\\"id\\": 22
|
||||
}
|
||||
],
|
||||
\\"id\\": 21
|
||||
},
|
||||
{
|
||||
\\"type\\": 3,
|
||||
\\"textContent\\": \\"\\\\n \\",
|
||||
\\"id\\": 23
|
||||
},
|
||||
{
|
||||
\\"type\\": 2,
|
||||
\\"tagName\\": \\"button\\",
|
||||
\\"attributes\\": {
|
||||
\\"slot\\": \\"title\\",
|
||||
\\"role\\": \\"tab\\",
|
||||
\\"tabindex\\": \\"-1\\",
|
||||
\\"aria-selected\\": \\"false\\"
|
||||
},
|
||||
\\"childNodes\\": [
|
||||
{
|
||||
\\"type\\": 3,
|
||||
\\"textContent\\": \\"Tab 3\\",
|
||||
\\"id\\": 25
|
||||
}
|
||||
],
|
||||
\\"id\\": 24
|
||||
},
|
||||
{
|
||||
\\"type\\": 3,
|
||||
\\"textContent\\": \\"\\\\n \\",
|
||||
\\"id\\": 26
|
||||
},
|
||||
{
|
||||
\\"type\\": 2,
|
||||
\\"tagName\\": \\"section\\",
|
||||
\\"attributes\\": {
|
||||
\\"role\\": \\"tabpanel\\",
|
||||
\\"tabindex\\": \\"0\\",
|
||||
\\"aria-hidden\\": \\"true\\"
|
||||
},
|
||||
\\"childNodes\\": [
|
||||
{
|
||||
\\"type\\": 3,
|
||||
\\"textContent\\": \\"content panel 1\\",
|
||||
\\"id\\": 28
|
||||
}
|
||||
],
|
||||
\\"id\\": 27
|
||||
},
|
||||
{
|
||||
\\"type\\": 3,
|
||||
\\"textContent\\": \\"\\\\n \\",
|
||||
\\"id\\": 29
|
||||
},
|
||||
{
|
||||
\\"type\\": 2,
|
||||
\\"tagName\\": \\"section\\",
|
||||
\\"attributes\\": {
|
||||
\\"role\\": \\"tabpanel\\",
|
||||
\\"tabindex\\": \\"0\\",
|
||||
\\"aria-hidden\\": \\"false\\"
|
||||
},
|
||||
\\"childNodes\\": [
|
||||
{
|
||||
\\"type\\": 3,
|
||||
\\"textContent\\": \\"content panel 2\\",
|
||||
\\"id\\": 31
|
||||
}
|
||||
],
|
||||
\\"id\\": 30
|
||||
},
|
||||
{
|
||||
\\"type\\": 3,
|
||||
\\"textContent\\": \\"\\\\n \\",
|
||||
\\"id\\": 32
|
||||
},
|
||||
{
|
||||
\\"type\\": 2,
|
||||
\\"tagName\\": \\"section\\",
|
||||
\\"attributes\\": {
|
||||
\\"role\\": \\"tabpanel\\",
|
||||
\\"tabindex\\": \\"0\\",
|
||||
\\"aria-hidden\\": \\"true\\"
|
||||
},
|
||||
\\"childNodes\\": [
|
||||
{
|
||||
\\"type\\": 3,
|
||||
\\"textContent\\": \\"content panel 3\\",
|
||||
\\"id\\": 34
|
||||
}
|
||||
],
|
||||
\\"id\\": 33
|
||||
},
|
||||
{
|
||||
\\"type\\": 3,
|
||||
\\"textContent\\": \\"\\\\n \\",
|
||||
\\"id\\": 35
|
||||
},
|
||||
{
|
||||
\\"type\\": 3,
|
||||
\\"textContent\\": \\"\\\\n \\",
|
||||
\\"id\\": 36,
|
||||
\\"isShadow\\": true
|
||||
},
|
||||
{
|
||||
\\"type\\": 2,
|
||||
\\"tagName\\": \\"style\\",
|
||||
\\"attributes\\": {},
|
||||
\\"childNodes\\": [
|
||||
{
|
||||
\\"type\\": 3,
|
||||
\\"textContent\\": \\"\\\\n :host {\\\\n display: inline-block;\\\\n width: 650px;\\\\n font-family: 'Roboto Slab';\\\\n contain: content;\\\\n }\\\\n :host([background]) {\\\\n background: var(--background-color, #9E9E9E);\\\\n border-radius: 10px;\\\\n padding: 10px;\\\\n }\\\\n #panels {\\\\n box-shadow: 0 2px 2px rgba(0, 0, 0, .3);\\\\n background: white;\\\\n border-radius: 3px;\\\\n padding: 16px;\\\\n height: 250px;\\\\n overflow: auto;\\\\n }\\\\n #tabs {\\\\n display: inline-flex;\\\\n -webkit-user-select: none;\\\\n user-select: none;\\\\n }\\\\n #tabs slot {\\\\n display: inline-flex; /* Safari bug. Treats <slot> as a parent */\\\\n }\\\\n /* Safari does not support #id prefixes on ::slotted\\\\n See https://bugs.webkit.org/show_bug.cgi?id=160538 */\\\\n #tabs ::slotted(*) {\\\\n font: 400 16px/22px 'Roboto';\\\\n padding: 16px 8px;\\\\n margin: 0;\\\\n text-align: center;\\\\n width: 100px;\\\\n text-overflow: ellipsis;\\\\n white-space: nowrap;\\\\n overflow: hidden;\\\\n cursor: pointer;\\\\n border-top-left-radius: 3px;\\\\n border-top-right-radius: 3px;\\\\n background: linear-gradient(#fafafa, #eee);\\\\n border: none; /* if the user users a <button> */\\\\n }\\\\n #tabs ::slotted([aria-selected=\\\\\\"true\\\\\\"]) {\\\\n font-weight: 600;\\\\n background: white;\\\\n box-shadow: none;\\\\n }\\\\n #tabs ::slotted(:focus) {\\\\n z-index: 1; /* make sure focus ring doesn't get buried */\\\\n }\\\\n #panels ::slotted([aria-hidden=\\\\\\"true\\\\\\"]) {\\\\n display: none;\\\\n }\\\\n \\",
|
||||
\\"isStyle\\": true,
|
||||
\\"id\\": 38
|
||||
}
|
||||
],
|
||||
\\"id\\": 37,
|
||||
\\"isShadow\\": true
|
||||
},
|
||||
{
|
||||
\\"type\\": 3,
|
||||
\\"textContent\\": \\"\\\\n \\",
|
||||
\\"id\\": 39,
|
||||
\\"isShadow\\": true
|
||||
},
|
||||
{
|
||||
\\"type\\": 2,
|
||||
\\"tagName\\": \\"div\\",
|
||||
\\"attributes\\": {
|
||||
\\"id\\": \\"tabs\\"
|
||||
},
|
||||
\\"childNodes\\": [
|
||||
{
|
||||
\\"type\\": 3,
|
||||
\\"textContent\\": \\"\\\\n \\",
|
||||
\\"id\\": 41
|
||||
},
|
||||
{
|
||||
\\"type\\": 2,
|
||||
\\"tagName\\": \\"slot\\",
|
||||
\\"attributes\\": {
|
||||
\\"id\\": \\"tabsSlot\\",
|
||||
\\"name\\": \\"title\\"
|
||||
},
|
||||
\\"childNodes\\": [],
|
||||
\\"id\\": 42
|
||||
},
|
||||
{
|
||||
\\"type\\": 3,
|
||||
\\"textContent\\": \\"\\\\n \\",
|
||||
\\"id\\": 43
|
||||
}
|
||||
],
|
||||
\\"id\\": 40,
|
||||
\\"isShadow\\": true
|
||||
},
|
||||
{
|
||||
\\"type\\": 3,
|
||||
\\"textContent\\": \\"\\\\n \\",
|
||||
\\"id\\": 44,
|
||||
\\"isShadow\\": true
|
||||
},
|
||||
{
|
||||
\\"type\\": 2,
|
||||
\\"tagName\\": \\"div\\",
|
||||
\\"attributes\\": {
|
||||
\\"id\\": \\"panels\\"
|
||||
},
|
||||
\\"childNodes\\": [
|
||||
{
|
||||
\\"type\\": 3,
|
||||
\\"textContent\\": \\"\\\\n \\",
|
||||
\\"id\\": 46
|
||||
},
|
||||
{
|
||||
\\"type\\": 2,
|
||||
\\"tagName\\": \\"slot\\",
|
||||
\\"attributes\\": {
|
||||
\\"id\\": \\"panelsSlot\\"
|
||||
},
|
||||
\\"childNodes\\": [],
|
||||
\\"id\\": 47
|
||||
},
|
||||
{
|
||||
\\"type\\": 3,
|
||||
\\"textContent\\": \\"\\\\n \\",
|
||||
\\"id\\": 48
|
||||
}
|
||||
],
|
||||
\\"id\\": 45,
|
||||
\\"isShadow\\": true
|
||||
},
|
||||
{
|
||||
\\"type\\": 3,
|
||||
\\"textContent\\": \\"\\\\n \\",
|
||||
\\"id\\": 49,
|
||||
\\"isShadow\\": true
|
||||
}
|
||||
],
|
||||
\\"id\\": 16,
|
||||
\\"isShadowHost\\": true
|
||||
},
|
||||
{
|
||||
\\"type\\": 3,
|
||||
\\"textContent\\": \\"\\\\n \\",
|
||||
\\"id\\": 50
|
||||
},
|
||||
{
|
||||
\\"type\\": 2,
|
||||
\\"tagName\\": \\"script\\",
|
||||
\\"attributes\\": {},
|
||||
\\"childNodes\\": [
|
||||
{
|
||||
\\"type\\": 3,
|
||||
\\"textContent\\": \\"SCRIPT_PLACEHOLDER\\",
|
||||
\\"id\\": 52
|
||||
}
|
||||
],
|
||||
\\"id\\": 51
|
||||
},
|
||||
{
|
||||
\\"type\\": 3,
|
||||
\\"textContent\\": \\"\\\\n \\\\n\\\\n\\",
|
||||
\\"id\\": 53
|
||||
}
|
||||
],
|
||||
\\"id\\": 14
|
||||
}
|
||||
],
|
||||
\\"id\\": 3
|
||||
}
|
||||
],
|
||||
\\"id\\": 1
|
||||
}"
|
||||
`;
|
||||
111
packages/rrweb-snapshot/test/css.test.ts
Normal file
111
packages/rrweb-snapshot/test/css.test.ts
Normal file
@@ -0,0 +1,111 @@
|
||||
import 'mocha';
|
||||
import { expect } from 'chai';
|
||||
import { parse, Rule, Media } from '../src/css';
|
||||
|
||||
describe('css parser', () => {
|
||||
it('should save the filename and source', () => {
|
||||
const css = 'booty {\n size: large;\n}\n';
|
||||
const ast = parse(css, {
|
||||
source: 'booty.css',
|
||||
});
|
||||
|
||||
expect(ast.stylesheet!.source).to.equal('booty.css');
|
||||
|
||||
const position = ast.stylesheet!.rules[0].position!;
|
||||
expect(position.start).to.be.ok;
|
||||
expect(position.end).to.be.ok;
|
||||
expect(position.source).to.equal('booty.css');
|
||||
expect(position.content).to.equal(css);
|
||||
});
|
||||
|
||||
it('should throw when a selector is missing', () => {
|
||||
expect(() => {
|
||||
parse('{size: large}');
|
||||
}).to.throw();
|
||||
|
||||
expect(() => {
|
||||
parse('b { color: red; }\n{ color: green; }\na { color: blue; }');
|
||||
}).to.throw();
|
||||
});
|
||||
|
||||
it('should throw when a broken comment is found', () => {
|
||||
expect(() => {
|
||||
parse('thing { color: red; } /* b { color: blue; }');
|
||||
}).to.throw();
|
||||
|
||||
expect(() => {
|
||||
parse('/*');
|
||||
}).to.throw();
|
||||
|
||||
/* Nested comments should be fine */
|
||||
expect(() => {
|
||||
parse('/* /* */');
|
||||
}).to.not.throw();
|
||||
});
|
||||
|
||||
it('should allow empty property value', () => {
|
||||
expect(() => {
|
||||
parse('p { color:; }');
|
||||
}).to.not.throw();
|
||||
});
|
||||
|
||||
it('should not throw with silent option', () => {
|
||||
expect(() => {
|
||||
parse('thing { color: red; } /* b { color: blue; }', { silent: true });
|
||||
}).to.not.throw();
|
||||
});
|
||||
|
||||
it('should list the parsing errors and continue parsing', () => {
|
||||
const result = parse(
|
||||
'foo { color= red; } bar { color: blue; } baz {}} boo { display: none}',
|
||||
{
|
||||
silent: true,
|
||||
source: 'foo.css',
|
||||
},
|
||||
);
|
||||
|
||||
const rules = result.stylesheet!.rules;
|
||||
expect(rules.length).to.above(2);
|
||||
|
||||
const errors = result.stylesheet!.parsingErrors!;
|
||||
expect(errors.length).to.equal(2);
|
||||
|
||||
expect(errors[0]).to.have.property('message');
|
||||
expect(errors[0]).to.have.property('reason');
|
||||
expect(errors[0]).to.have.property('filename');
|
||||
expect(errors[0]).to.have.property('line');
|
||||
expect(errors[0]).to.have.property('column');
|
||||
expect(errors[0]).to.have.property('source');
|
||||
expect(errors[0].filename).to.equal('foo.css');
|
||||
});
|
||||
|
||||
it('should set parent property', () => {
|
||||
const result = parse(
|
||||
'thing { test: value; }\n' +
|
||||
'@media (min-width: 100px) { thing { test: value; } }',
|
||||
);
|
||||
|
||||
expect(result.parent).to.equal(null);
|
||||
|
||||
const rules = result.stylesheet!.rules;
|
||||
expect(rules.length).to.equal(2);
|
||||
|
||||
let rule = rules[0] as Rule;
|
||||
expect(rule.parent).to.equal(result);
|
||||
expect(rule.declarations!.length).to.equal(1);
|
||||
|
||||
let decl = rule.declarations![0];
|
||||
expect(decl.parent).to.equal(rule);
|
||||
|
||||
const media = rules[1] as Media;
|
||||
expect(media.parent).to.equal(result);
|
||||
expect(media.rules!.length).to.equal(1);
|
||||
|
||||
rule = media.rules![0] as Rule;
|
||||
expect(rule.parent).to.equal(media);
|
||||
|
||||
expect(rule.declarations!.length).to.equal(1);
|
||||
decl = rule.declarations![0];
|
||||
expect(decl.parent).to.equal(rule);
|
||||
});
|
||||
});
|
||||
6
packages/rrweb-snapshot/test/css/benchmark.css
Normal file
6
packages/rrweb-snapshot/test/css/benchmark.css
Normal file
File diff suppressed because one or more lines are too long
1
packages/rrweb-snapshot/test/css/style-with-import.css
vendored
Normal file
1
packages/rrweb-snapshot/test/css/style-with-import.css
vendored
Normal file
@@ -0,0 +1 @@
|
||||
@import "./style.css";
|
||||
12
packages/rrweb-snapshot/test/css/style.css
Normal file
12
packages/rrweb-snapshot/test/css/style.css
Normal file
@@ -0,0 +1,12 @@
|
||||
body {
|
||||
margin: 0;
|
||||
background: url('../a.jpg');
|
||||
border-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" x="0px" y="0px" viewBox="0 0 256 256"><g><g><polygon points="79.093,0 48.907,30.187 146.72,128 48.907,225.813 79.093,256 207.093,128"/></g></g></svg>');
|
||||
}
|
||||
p {
|
||||
color: red;
|
||||
background: url('./b.jpg');
|
||||
}
|
||||
body > p {
|
||||
color: yellow;
|
||||
}
|
||||
57
packages/rrweb-snapshot/test/html/about-mozilla.html
Normal file
57
packages/rrweb-snapshot/test/html/about-mozilla.html
Normal file
@@ -0,0 +1,57 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<title>The Book of Mozilla, 11:9</title>
|
||||
<style type="text/css">
|
||||
html {
|
||||
background: maroon;
|
||||
color: white;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
#moztext {
|
||||
margin-top: 15%;
|
||||
font-size: 1.1em;
|
||||
font-family: serif;
|
||||
text-align: center;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
#from {
|
||||
font-size: 1.95em;
|
||||
font-family: serif;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
em {
|
||||
font-size: 1.3em;
|
||||
line-height: 0;
|
||||
}
|
||||
|
||||
a {
|
||||
text-decoration: none;
|
||||
color: white;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<p id="moztext">
|
||||
Mammon slept. And the <em>beast reborn</em> spread over the earth and its numbers
|
||||
grew legion. And they proclaimed the times and <em>sacrificed</em> crops unto the
|
||||
fire, with the <em>cunning of foxes</em>. And they built a new world in their own
|
||||
image as promised by the <em><a href="http://www.mozilla.org/about/mozilla-manifesto.html">
|
||||
sacred words</a></em>, and <em><a href="http://wiki.mozilla.org/About:mozilla">spoke
|
||||
</a></em> of the beast with their children. Mammon awoke, and lo! it was
|
||||
<em>naught</em> but a follower.
|
||||
</p>
|
||||
|
||||
<p id="from">
|
||||
from <strong>The Book of Mozilla,</strong> 11:9<br /><small>(10th Edition)</small>
|
||||
</p>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
15
packages/rrweb-snapshot/test/html/basic.html
Normal file
15
packages/rrweb-snapshot/test/html/basic.html
Normal file
@@ -0,0 +1,15 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||
<title>Document</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1>Title</h1>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
27
packages/rrweb-snapshot/test/html/block-element.html
Normal file
27
packages/rrweb-snapshot/test/html/block-element.html
Normal file
@@ -0,0 +1,27 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
|
||||
<title>Document</title>
|
||||
<style>
|
||||
.big {
|
||||
width: 50px;
|
||||
height: 50px;
|
||||
}
|
||||
.small {
|
||||
width: 50px;
|
||||
height: 100px;
|
||||
float: left;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="rr-block big">block 1</div>
|
||||
<div>record 2</div>
|
||||
<div class="rr-block small">block 3</div>
|
||||
<div class="rr-block" style="height: 200px; width: 100px">block 3</div>
|
||||
</body>
|
||||
</html>
|
||||
15
packages/rrweb-snapshot/test/html/cors-style-sheet.html
Normal file
15
packages/rrweb-snapshot/test/html/cors-style-sheet.html
Normal file
@@ -0,0 +1,15 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
|
||||
<title>with style sheet</title>
|
||||
<link
|
||||
rel="stylesheet"
|
||||
href="https://cdn.jsdelivr.net/npm/pure@2.85.0/index.css"
|
||||
/>
|
||||
<link rel="stylesheet" href />
|
||||
</head>
|
||||
<body></body>
|
||||
</html>
|
||||
20
packages/rrweb-snapshot/test/html/dynamic-stylesheet.html
Normal file
20
packages/rrweb-snapshot/test/html/dynamic-stylesheet.html
Normal file
@@ -0,0 +1,20 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
|
||||
<title>dynamic stylesheet</title>
|
||||
<style></style>
|
||||
<script>
|
||||
const styleEl = document.querySelector('style');
|
||||
const rules = [`body { margin: 0 }`, `p { background: lightpink }`];
|
||||
rules.forEach((rule, idx) => {
|
||||
styleEl.sheet.insertRule(rule, idx);
|
||||
});
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<p>p tag</p>
|
||||
</body>
|
||||
</html>
|
||||
42
packages/rrweb-snapshot/test/html/form-fields.html
Normal file
42
packages/rrweb-snapshot/test/html/form-fields.html
Normal file
@@ -0,0 +1,42 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
|
||||
<title>form fields</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<form>
|
||||
<label for="text">
|
||||
<input type="text" />
|
||||
</label>
|
||||
<label for="radio">
|
||||
<input type="radio" />
|
||||
</label>
|
||||
<label for="checkbox">
|
||||
<input type="checkbox" />
|
||||
</label>
|
||||
<label for="textarea">
|
||||
<textarea name="" id="" cols="30" rows="10"></textarea>
|
||||
</label>
|
||||
<label for="select">
|
||||
<select name="" id="">
|
||||
<option value="1">1</option>
|
||||
<option value="2">2</option>
|
||||
</select>
|
||||
</label>
|
||||
<label>
|
||||
<input name="tagName" />
|
||||
</label>
|
||||
</form>
|
||||
</body>
|
||||
<script>
|
||||
document.querySelector('input[type="text"]').value = '1';
|
||||
document.querySelector('input[type="radio"]').checked = true;
|
||||
document.querySelector('input[type="checkbox"]').checked = true;
|
||||
document.querySelector('textarea').value = '1234';
|
||||
document.querySelector('select').value = '2';
|
||||
</script>
|
||||
</html>
|
||||
31
packages/rrweb-snapshot/test/html/hover.html
Normal file
31
packages/rrweb-snapshot/test/html/hover.html
Normal file
@@ -0,0 +1,31 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||
<title>hover selector</title>
|
||||
<style>
|
||||
|
||||
div:hover {
|
||||
background: orange;
|
||||
}
|
||||
|
||||
div:hover::after {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 100%;
|
||||
content: 'dropdown';
|
||||
width: 100px;
|
||||
height: 200px;
|
||||
background: lightblue;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div>hover me</div>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
1
packages/rrweb-snapshot/test/html/iframe-inner.html
Normal file
1
packages/rrweb-snapshot/test/html/iframe-inner.html
Normal file
@@ -0,0 +1 @@
|
||||
<button>inner iframe button</button>
|
||||
12
packages/rrweb-snapshot/test/html/iframe.html
Normal file
12
packages/rrweb-snapshot/test/html/iframe.html
Normal file
@@ -0,0 +1,12 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||
<title>iframe</title>
|
||||
</head>
|
||||
<body>
|
||||
<iframe src="/html/iframe-inner.html" width="100" height="50"></iframe>
|
||||
</body>
|
||||
</html>
|
||||
3
packages/rrweb-snapshot/test/html/invalid-attribute.html
Normal file
3
packages/rrweb-snapshot/test/html/invalid-attribute.html
Normal file
@@ -0,0 +1,3 @@
|
||||
<html foo='bar' ''>
|
||||
|
||||
</html>
|
||||
9
packages/rrweb-snapshot/test/html/invalid-doctype.html
Normal file
9
packages/rrweb-snapshot/test/html/invalid-doctype.html
Normal file
@@ -0,0 +1,9 @@
|
||||
<!DOCTYPE >
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Invalid Doctype</title>
|
||||
</head>
|
||||
<body></body>
|
||||
</html>
|
||||
14
packages/rrweb-snapshot/test/html/invalid-tagname.html
Normal file
14
packages/rrweb-snapshot/test/html/invalid-tagname.html
Normal file
@@ -0,0 +1,14 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||
<title>Document</title>
|
||||
</head>
|
||||
<body>
|
||||
<alt="">Hello</alt="">
|
||||
<d123-_+!@#$%^&*()>Hello</d123-_+!@#$%^&*()>
|
||||
<ale#></ale#>
|
||||
</body>
|
||||
</html>
|
||||
17
packages/rrweb-snapshot/test/html/mask-text.html
Normal file
17
packages/rrweb-snapshot/test/html/mask-text.html
Normal file
@@ -0,0 +1,17 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
|
||||
<title>Document</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<p class="rr-mask">mask 1</p>
|
||||
<div class="rr-mask">
|
||||
<span>mask 2</span>
|
||||
</div>
|
||||
<div class="rr-mask">mask 3</div>
|
||||
</body>
|
||||
</html>
|
||||
8
packages/rrweb-snapshot/test/html/picture.html
Normal file
8
packages/rrweb-snapshot/test/html/picture.html
Normal file
@@ -0,0 +1,8 @@
|
||||
<html>
|
||||
<body>
|
||||
<picture>
|
||||
<source type="image/webp" srcset="assets/img/characters/robot.webp" />
|
||||
<img src="assets/img/characters/robot.png" />
|
||||
</picture>
|
||||
</body>
|
||||
</html>
|
||||
11
packages/rrweb-snapshot/test/html/preload.html
Normal file
11
packages/rrweb-snapshot/test/html/preload.html
Normal file
@@ -0,0 +1,11 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Document</title>
|
||||
<link rel="preload" href="https://example/path/to/preload.js" as="script" />
|
||||
<link rel="prefetch" href="https://example/path/to/prefetch.js" />
|
||||
</head>
|
||||
<body></body>
|
||||
</html>
|
||||
209
packages/rrweb-snapshot/test/html/shadow-dom.html
Normal file
209
packages/rrweb-snapshot/test/html/shadow-dom.html
Normal file
@@ -0,0 +1,209 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>shadow DOM</title>
|
||||
</head>
|
||||
<body>
|
||||
<fancy-tabs background>
|
||||
<button slot="title">Tab 1</button>
|
||||
<button slot="title" selected>Tab 2</button>
|
||||
<button slot="title">Tab 3</button>
|
||||
<section>content panel 1</section>
|
||||
<section>content panel 2</section>
|
||||
<section>content panel 3</section>
|
||||
</fancy-tabs>
|
||||
<script>
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
// Feature detect
|
||||
if (!(window.customElements && document.body.attachShadow)) {
|
||||
document.querySelector('fancy-tabs').innerHTML =
|
||||
"<b>Your browser doesn't support Shadow DOM and Custom Elements v1.</b>";
|
||||
return;
|
||||
}
|
||||
|
||||
let selected_ = null;
|
||||
|
||||
// See https://www.w3.org/TR/wai-aria-practices-1.1/#tabpanel
|
||||
|
||||
customElements.define(
|
||||
'fancy-tabs',
|
||||
class extends HTMLElement {
|
||||
constructor() {
|
||||
super(); // always call super() first in the ctor.
|
||||
|
||||
// Create shadow DOM for the component.
|
||||
let shadowRoot = this.attachShadow({ mode: 'open' });
|
||||
shadowRoot.innerHTML = `
|
||||
<style>
|
||||
:host {
|
||||
display: inline-block;
|
||||
width: 650px;
|
||||
font-family: 'Roboto Slab';
|
||||
contain: content;
|
||||
}
|
||||
:host([background]) {
|
||||
background: var(--background-color, #9E9E9E);
|
||||
border-radius: 10px;
|
||||
padding: 10px;
|
||||
}
|
||||
#panels {
|
||||
box-shadow: 0 2px 2px rgba(0, 0, 0, .3);
|
||||
background: white;
|
||||
border-radius: 3px;
|
||||
padding: 16px;
|
||||
height: 250px;
|
||||
overflow: auto;
|
||||
}
|
||||
#tabs {
|
||||
display: inline-flex;
|
||||
-webkit-user-select: none;
|
||||
user-select: none;
|
||||
}
|
||||
#tabs slot {
|
||||
display: inline-flex; /* Safari bug. Treats <slot> as a parent */
|
||||
}
|
||||
/* Safari does not support #id prefixes on ::slotted
|
||||
See https://bugs.webkit.org/show_bug.cgi?id=160538 */
|
||||
#tabs ::slotted(*) {
|
||||
font: 400 16px/22px 'Roboto';
|
||||
padding: 16px 8px;
|
||||
margin: 0;
|
||||
text-align: center;
|
||||
width: 100px;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
cursor: pointer;
|
||||
border-top-left-radius: 3px;
|
||||
border-top-right-radius: 3px;
|
||||
background: linear-gradient(#fafafa, #eee);
|
||||
border: none; /* if the user users a <button> */
|
||||
}
|
||||
#tabs ::slotted([aria-selected="true"]) {
|
||||
font-weight: 600;
|
||||
background: white;
|
||||
box-shadow: none;
|
||||
}
|
||||
#tabs ::slotted(:focus) {
|
||||
z-index: 1; /* make sure focus ring doesn't get buried */
|
||||
}
|
||||
#panels ::slotted([aria-hidden="true"]) {
|
||||
display: none;
|
||||
}
|
||||
</style>
|
||||
<div id="tabs">
|
||||
<slot id="tabsSlot" name="title"></slot>
|
||||
</div>
|
||||
<div id="panels">
|
||||
<slot id="panelsSlot"></slot>
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
|
||||
get selected() {
|
||||
return selected_;
|
||||
}
|
||||
|
||||
set selected(idx) {
|
||||
selected_ = idx;
|
||||
this._selectTab(idx);
|
||||
|
||||
// Updated the element's selected attribute value when
|
||||
// backing property changes.
|
||||
this.setAttribute('selected', idx);
|
||||
}
|
||||
|
||||
connectedCallback() {
|
||||
this.setAttribute('role', 'tablist');
|
||||
|
||||
const tabsSlot = this.shadowRoot.querySelector('#tabsSlot');
|
||||
const panelsSlot = this.shadowRoot.querySelector('#panelsSlot');
|
||||
|
||||
this.tabs = tabsSlot.assignedNodes({ flatten: true });
|
||||
this.panels = panelsSlot
|
||||
.assignedNodes({ flatten: true })
|
||||
.filter((el) => {
|
||||
return el.nodeType === Node.ELEMENT_NODE;
|
||||
});
|
||||
|
||||
// Add aria role="tabpanel" to each content panel.
|
||||
for (let [i, panel] of this.panels.entries()) {
|
||||
panel.setAttribute('role', 'tabpanel');
|
||||
panel.setAttribute('tabindex', 0);
|
||||
}
|
||||
|
||||
// Save refer to we can remove listeners later.
|
||||
this._boundOnTitleClick = this._onTitleClick.bind(this);
|
||||
this._boundOnKeyDown = this._onKeyDown.bind(this);
|
||||
|
||||
tabsSlot.addEventListener('click', this._boundOnTitleClick);
|
||||
tabsSlot.addEventListener('keydown', this._boundOnKeyDown);
|
||||
|
||||
this.selected = this._findFirstSelectedTab() || 0;
|
||||
}
|
||||
|
||||
disconnectedCallback() {
|
||||
const tabsSlot = this.shadowRoot.querySelector('#tabsSlot');
|
||||
tabsSlot.removeEventListener('click', this._boundOnTitleClick);
|
||||
tabsSlot.removeEventListener('keydown', this._boundOnKeyDown);
|
||||
}
|
||||
|
||||
_onTitleClick(e) {
|
||||
if (e.target.slot === 'title') {
|
||||
this.selected = this.tabs.indexOf(e.target);
|
||||
e.target.focus();
|
||||
}
|
||||
}
|
||||
|
||||
_onKeyDown(e) {
|
||||
switch (e.code) {
|
||||
case 'ArrowUp':
|
||||
case 'ArrowLeft':
|
||||
e.preventDefault();
|
||||
var idx = this.selected - 1;
|
||||
idx = idx < 0 ? this.tabs.length - 1 : idx;
|
||||
this.tabs[idx].click();
|
||||
break;
|
||||
case 'ArrowDown':
|
||||
case 'ArrowRight':
|
||||
e.preventDefault();
|
||||
var idx = this.selected + 1;
|
||||
this.tabs[idx % this.tabs.length].click();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
_findFirstSelectedTab() {
|
||||
let selectedIdx;
|
||||
for (let [i, tab] of this.tabs.entries()) {
|
||||
tab.setAttribute('role', 'tab');
|
||||
|
||||
// Allow users to declaratively select a tab
|
||||
// Highlight last tab which has the selected attribute.
|
||||
if (tab.hasAttribute('selected')) {
|
||||
selectedIdx = i;
|
||||
}
|
||||
}
|
||||
return selectedIdx;
|
||||
}
|
||||
|
||||
_selectTab(idx = null) {
|
||||
for (let i = 0, tab; (tab = this.tabs[i]); ++i) {
|
||||
let select = i === idx;
|
||||
tab.setAttribute('tabindex', select ? 0 : -1);
|
||||
tab.setAttribute('aria-selected', select);
|
||||
this.panels[i].setAttribute('aria-hidden', !select);
|
||||
}
|
||||
}
|
||||
},
|
||||
);
|
||||
})();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
19
packages/rrweb-snapshot/test/html/video.html
Normal file
19
packages/rrweb-snapshot/test/html/video.html
Normal file
@@ -0,0 +1,19 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
|
||||
<title>video</title>
|
||||
</head>
|
||||
<body>
|
||||
<video controls>
|
||||
<source src=http://techslides.com/demos/sample-videos/small.webm
|
||||
type=video/webm> <source
|
||||
src=http://techslides.com/demos/sample-videos/small.ogv type=video/ogg>
|
||||
<source src=http://techslides.com/demos/sample-videos/small.mp4
|
||||
type=video/mp4> <source
|
||||
src=http://techslides.com/demos/sample-videos/small.3gp type=video/3gp>
|
||||
</video>
|
||||
</body>
|
||||
</html>
|
||||
21
packages/rrweb-snapshot/test/html/with-relative-res.html
Normal file
21
packages/rrweb-snapshot/test/html/with-relative-res.html
Normal file
@@ -0,0 +1,21 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||
<title>Document</title>
|
||||
</head>
|
||||
<body>
|
||||
<a href="./basic.html"></a>
|
||||
<alt="">Hello</alt="">
|
||||
<alt34>Hello</alt34>
|
||||
<d123-_+!@#$%^&*()>Hello</d123-_+!@#$%^&*()>
|
||||
<ale#></ale#>
|
||||
<img src="./a.jpg" alt="" srcset="">
|
||||
<img src="./a.jpg" alt="" srcset="/a.jpg">
|
||||
<img src="./a.jpg" alt="" srcset="http://exmple.com/a.jpg ">
|
||||
<img src="./a.jpg" alt="" srcset="/a.jpg 3x, /a.jpg 45x , /b.png">
|
||||
<img src="./a.jpg" alt="" srcset="/300,400/a.jpg 300w,b.png">
|
||||
</body>
|
||||
</html>
|
||||
18
packages/rrweb-snapshot/test/html/with-script.html
Normal file
18
packages/rrweb-snapshot/test/html/with-script.html
Normal file
@@ -0,0 +1,18 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||
<title>with script</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<script src="/js/a.js"></script>
|
||||
<script>
|
||||
var a = 1 + 1;
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -0,0 +1,16 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||
<title>with style sheet with import</title>
|
||||
<link rel="stylesheet" href="/css/style-with-import.css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
16
packages/rrweb-snapshot/test/html/with-style-sheet.html
Normal file
16
packages/rrweb-snapshot/test/html/with-style-sheet.html
Normal file
@@ -0,0 +1,16 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||
<title>with style sheet</title>
|
||||
<link rel="stylesheet" href="/css/style.css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
13
packages/rrweb-snapshot/test/iframe-html/frame1.html
Normal file
13
packages/rrweb-snapshot/test/iframe-html/frame1.html
Normal file
@@ -0,0 +1,13 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Frame 1</title>
|
||||
</head>
|
||||
<body>
|
||||
frame 1
|
||||
<iframe id="three" frameborder="0"></iframe>
|
||||
<iframe id="four" src="./frame2.html" frameborder="0"></iframe>
|
||||
</body>
|
||||
</html>
|
||||
11
packages/rrweb-snapshot/test/iframe-html/frame2.html
Normal file
11
packages/rrweb-snapshot/test/iframe-html/frame2.html
Normal file
@@ -0,0 +1,11 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Frame 2</title>
|
||||
</head>
|
||||
<body>
|
||||
frame 2
|
||||
</body>
|
||||
</html>
|
||||
12
packages/rrweb-snapshot/test/iframe-html/main.html
Normal file
12
packages/rrweb-snapshot/test/iframe-html/main.html
Normal file
@@ -0,0 +1,12 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Main</title>
|
||||
</head>
|
||||
<body>
|
||||
<iframe id="one"></iframe>
|
||||
<iframe id="two" src="./frame1.html"></iframe>
|
||||
</body>
|
||||
</html>
|
||||
215
packages/rrweb-snapshot/test/integration.ts
Normal file
215
packages/rrweb-snapshot/test/integration.ts
Normal file
@@ -0,0 +1,215 @@
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
import * as http from 'http';
|
||||
import * as url from 'url';
|
||||
import 'mocha';
|
||||
import * as puppeteer from 'puppeteer';
|
||||
import * as rollup from 'rollup';
|
||||
import typescript = require('rollup-plugin-typescript');
|
||||
import { assert } from 'chai';
|
||||
import { SnapshotState, toMatchSnapshot } from 'jest-snapshot';
|
||||
import { Suite } from 'mocha';
|
||||
|
||||
const htmlFolder = path.join(__dirname, 'html');
|
||||
const htmls = fs.readdirSync(htmlFolder).map((filePath) => {
|
||||
const raw = fs.readFileSync(path.resolve(htmlFolder, filePath), 'utf-8');
|
||||
return {
|
||||
filePath,
|
||||
src: raw,
|
||||
};
|
||||
});
|
||||
|
||||
interface IMimeType {
|
||||
[key: string]: string;
|
||||
}
|
||||
|
||||
const server = () =>
|
||||
new Promise<http.Server>((resolve) => {
|
||||
const mimeType: IMimeType = {
|
||||
'.html': 'text/html',
|
||||
'.js': 'text/javascript',
|
||||
'.css': 'text/css',
|
||||
};
|
||||
const s = http.createServer((req, res) => {
|
||||
const parsedUrl = url.parse(req.url!);
|
||||
const sanitizePath = path
|
||||
.normalize(parsedUrl.pathname!)
|
||||
.replace(/^(\.\.[\/\\])+/, '');
|
||||
let pathname = path.join(__dirname, sanitizePath);
|
||||
try {
|
||||
const data = fs.readFileSync(pathname);
|
||||
const ext = path.parse(pathname).ext;
|
||||
res.setHeader('Content-type', mimeType[ext] || 'text/plain');
|
||||
res.setHeader('Access-Control-Allow-Origin', '*');
|
||||
res.setHeader('Access-Control-Allow-Methods', 'GET');
|
||||
res.setHeader('Access-Control-Allow-Headers', 'Content-type');
|
||||
res.end(data);
|
||||
} catch (error) {
|
||||
res.end();
|
||||
}
|
||||
});
|
||||
s.listen(3030).on('listening', () => {
|
||||
resolve(s);
|
||||
});
|
||||
});
|
||||
|
||||
function matchSnapshot(actual: string, testFile: string, testTitle: string) {
|
||||
const snapshotState = new SnapshotState(testFile, {
|
||||
updateSnapshot: process.env.SNAPSHOT_UPDATE ? 'all' : 'new',
|
||||
});
|
||||
|
||||
const matcher = toMatchSnapshot.bind({
|
||||
snapshotState,
|
||||
currentTestName: testTitle,
|
||||
});
|
||||
const result = matcher(actual);
|
||||
snapshotState.save();
|
||||
return result;
|
||||
}
|
||||
|
||||
interface ISuite extends Suite {
|
||||
server: http.Server;
|
||||
browser: puppeteer.Browser;
|
||||
code: string;
|
||||
}
|
||||
|
||||
describe('integration tests', function (this: ISuite) {
|
||||
before(async () => {
|
||||
this.server = await server();
|
||||
this.browser = await puppeteer.launch({
|
||||
// headless: false,
|
||||
});
|
||||
|
||||
const bundle = await rollup.rollup({
|
||||
input: path.resolve(__dirname, '../src/index.ts'),
|
||||
plugins: [typescript()],
|
||||
});
|
||||
const { code } = await bundle.generate({
|
||||
name: 'rrweb',
|
||||
format: 'iife',
|
||||
});
|
||||
this.code = code;
|
||||
});
|
||||
|
||||
after(async () => {
|
||||
await this.browser.close();
|
||||
await this.server.close();
|
||||
});
|
||||
|
||||
for (const html of htmls) {
|
||||
const title = '[html file]: ' + html.filePath;
|
||||
it(title, async () => {
|
||||
const page: puppeteer.Page = await this.browser.newPage();
|
||||
// console for debug
|
||||
// tslint:disable-next-line: no-console
|
||||
page.on('console', (msg) => console.log(msg.text()));
|
||||
await page.goto(`http://localhost:3030/html`);
|
||||
await page.setContent(html.src, {
|
||||
waitUntil: 'load',
|
||||
});
|
||||
const rebuildHtml = (
|
||||
await page.evaluate(`${this.code}
|
||||
const x = new XMLSerializer();
|
||||
const [snap] = rrweb.snapshot(document);
|
||||
x.serializeToString(rrweb.rebuild(snap, { doc: document })[0]);
|
||||
`)
|
||||
).replace(/\n\n/g, '');
|
||||
const result = matchSnapshot(rebuildHtml, __filename, title);
|
||||
assert(result.pass, result.pass ? '' : result.report());
|
||||
}).timeout(5000);
|
||||
}
|
||||
});
|
||||
|
||||
describe('iframe integration tests', function (this: ISuite) {
|
||||
const iframeHtml = path.join(__dirname, 'iframe-html/main.html');
|
||||
const raw = fs.readFileSync(iframeHtml, 'utf-8');
|
||||
|
||||
before(async () => {
|
||||
this.server = await server();
|
||||
this.browser = await puppeteer.launch({
|
||||
// headless: false,
|
||||
});
|
||||
|
||||
const bundle = await rollup.rollup({
|
||||
input: path.resolve(__dirname, '../src/index.ts'),
|
||||
plugins: [typescript()],
|
||||
});
|
||||
const { code } = await bundle.generate({
|
||||
name: 'rrweb',
|
||||
format: 'iife',
|
||||
});
|
||||
this.code = code;
|
||||
});
|
||||
|
||||
after(async () => {
|
||||
await this.browser.close();
|
||||
await this.server.close();
|
||||
});
|
||||
|
||||
it('snapshot async iframes', async () => {
|
||||
const page: puppeteer.Page = await this.browser.newPage();
|
||||
// console for debug
|
||||
// tslint:disable-next-line: no-console
|
||||
page.on('console', (msg) => console.log(msg.text()));
|
||||
await page.goto(`http://localhost:3030/html`);
|
||||
await page.setContent(raw, {
|
||||
waitUntil: 'load',
|
||||
});
|
||||
const snapshotResult = JSON.stringify(
|
||||
await page.evaluate(`${this.code};
|
||||
rrweb.snapshot(document)[0];
|
||||
`),
|
||||
null,
|
||||
2,
|
||||
);
|
||||
const result = matchSnapshot(snapshotResult, __filename, this.title);
|
||||
assert(result.pass, result.pass ? '' : result.report());
|
||||
}).timeout(5000);
|
||||
});
|
||||
|
||||
describe('shadown DOM integration tests', function (this: ISuite) {
|
||||
const shadowDomHtml = path.join(__dirname, 'html/shadow-dom.html');
|
||||
const raw = fs.readFileSync(shadowDomHtml, 'utf-8');
|
||||
|
||||
before(async () => {
|
||||
this.server = await server();
|
||||
this.browser = await puppeteer.launch({
|
||||
// headless: false,
|
||||
});
|
||||
|
||||
const bundle = await rollup.rollup({
|
||||
input: path.resolve(__dirname, '../src/index.ts'),
|
||||
plugins: [typescript()],
|
||||
});
|
||||
const { code } = await bundle.generate({
|
||||
name: 'rrweb',
|
||||
format: 'iife',
|
||||
});
|
||||
this.code = code;
|
||||
});
|
||||
|
||||
after(async () => {
|
||||
await this.browser.close();
|
||||
await this.server.close();
|
||||
});
|
||||
|
||||
it('snapshot shadow DOM', async () => {
|
||||
const page: puppeteer.Page = await this.browser.newPage();
|
||||
// console for debug
|
||||
// tslint:disable-next-line: no-console
|
||||
page.on('console', (msg) => console.log(msg.text()));
|
||||
await page.goto(`http://localhost:3030/html`);
|
||||
await page.setContent(raw, {
|
||||
waitUntil: 'load',
|
||||
});
|
||||
const snapshotResult = JSON.stringify(
|
||||
await page.evaluate(`${this.code};
|
||||
rrweb.snapshot(document)[0];
|
||||
`),
|
||||
null,
|
||||
2,
|
||||
);
|
||||
const result = matchSnapshot(snapshotResult, __filename, this.title);
|
||||
assert(result.pass, result.pass ? '' : result.report());
|
||||
}).timeout(5000);
|
||||
});
|
||||
1
packages/rrweb-snapshot/test/js/a.js
Normal file
1
packages/rrweb-snapshot/test/js/a.js
Normal file
@@ -0,0 +1 @@
|
||||
var a = 1 + 1;
|
||||
64
packages/rrweb-snapshot/test/rebuild.test.ts
Normal file
64
packages/rrweb-snapshot/test/rebuild.test.ts
Normal file
@@ -0,0 +1,64 @@
|
||||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
import 'mocha';
|
||||
import { expect } from 'chai';
|
||||
import { addHoverClass } from '../src/rebuild';
|
||||
|
||||
describe('add hover class to hover selector related rules', () => {
|
||||
it('will do nothing to css text without :hover', () => {
|
||||
const cssText = 'body { color: white }';
|
||||
expect(addHoverClass(cssText)).to.equal(cssText);
|
||||
});
|
||||
|
||||
it('can add hover class to css text', () => {
|
||||
const cssText = '.a:hover { color: white }';
|
||||
expect(addHoverClass(cssText)).to.equal(
|
||||
'.a:hover, .a.\\:hover { color: white }',
|
||||
);
|
||||
});
|
||||
|
||||
it('can add hover class when there is multi selector', () => {
|
||||
const cssText = '.a, .b:hover, .c { color: white }';
|
||||
expect(addHoverClass(cssText)).to.equal(
|
||||
'.a, .b:hover, .b.\\:hover, .c { color: white }',
|
||||
);
|
||||
});
|
||||
|
||||
it('can add hover class when there is a multi selector with the same prefix', () => {
|
||||
const cssText = '.a:hover, .a:hover::after { color: white }';
|
||||
expect(addHoverClass(cssText)).to.equal(
|
||||
'.a:hover, .a.\\:hover, .a:hover::after, .a.\\:hover::after { color: white }',
|
||||
);
|
||||
});
|
||||
|
||||
it('can add hover class when :hover is not the end of selector', () => {
|
||||
const cssText = 'div:hover::after { color: white }';
|
||||
expect(addHoverClass(cssText)).to.equal(
|
||||
'div:hover::after, div.\\:hover::after { color: white }',
|
||||
);
|
||||
});
|
||||
|
||||
it('can add hover class when the selector has multi :hover', () => {
|
||||
const cssText = 'a:hover b:hover { color: white }';
|
||||
expect(addHoverClass(cssText)).to.equal(
|
||||
'a:hover b:hover, a.\\:hover b.\\:hover { color: white }',
|
||||
);
|
||||
});
|
||||
|
||||
it('will ignore :hover in css value', () => {
|
||||
const cssText = '.a::after { content: ":hover" }';
|
||||
expect(addHoverClass(cssText)).to.equal(cssText);
|
||||
});
|
||||
|
||||
it('benchmark', () => {
|
||||
const cssText = fs.readFileSync(
|
||||
path.resolve(__dirname, './css/benchmark.css'),
|
||||
'utf8',
|
||||
);
|
||||
const start = process.hrtime();
|
||||
addHoverClass(cssText);
|
||||
const end = process.hrtime(start);
|
||||
const duration = end[0] * 1_000 + end[1] / 1_000_000;
|
||||
expect(duration).to.below(100);
|
||||
});
|
||||
});
|
||||
130
packages/rrweb-snapshot/test/snapshot.test.ts
Normal file
130
packages/rrweb-snapshot/test/snapshot.test.ts
Normal file
@@ -0,0 +1,130 @@
|
||||
import 'mocha';
|
||||
import { JSDOM } from 'jsdom';
|
||||
import { expect } from 'chai';
|
||||
import { absoluteToStylesheet, _isBlockedElement } from '../src/snapshot';
|
||||
|
||||
describe('absolute url to stylesheet', () => {
|
||||
const href = 'http://localhost/css/style.css';
|
||||
|
||||
it('can handle relative path', () => {
|
||||
expect(absoluteToStylesheet('url(a.jpg)', href)).to.equal(
|
||||
`url(http://localhost/css/a.jpg)`,
|
||||
);
|
||||
});
|
||||
|
||||
it('can handle same level path', () => {
|
||||
expect(absoluteToStylesheet('url("./a.jpg")', href)).to.equal(
|
||||
`url("http://localhost/css/a.jpg")`,
|
||||
);
|
||||
});
|
||||
|
||||
it('can handle parent level path', () => {
|
||||
expect(absoluteToStylesheet('url("../a.jpg")', href)).to.equal(
|
||||
`url("http://localhost/a.jpg")`,
|
||||
);
|
||||
});
|
||||
|
||||
it('can handle absolute path', () => {
|
||||
expect(absoluteToStylesheet('url("/a.jpg")', href)).to.equal(
|
||||
`url("http://localhost/a.jpg")`,
|
||||
);
|
||||
});
|
||||
|
||||
it('can handle external path', () => {
|
||||
expect(
|
||||
absoluteToStylesheet('url("http://localhost/a.jpg")', href),
|
||||
).to.equal(`url("http://localhost/a.jpg")`);
|
||||
});
|
||||
|
||||
it('can handle single quote path', () => {
|
||||
expect(absoluteToStylesheet(`url('./a.jpg')`, href)).to.equal(
|
||||
`url('http://localhost/css/a.jpg')`,
|
||||
);
|
||||
});
|
||||
|
||||
it('can handle no quote path', () => {
|
||||
expect(absoluteToStylesheet('url(./a.jpg)', href)).to.equal(
|
||||
`url(http://localhost/css/a.jpg)`,
|
||||
);
|
||||
});
|
||||
|
||||
it('can handle multiple no quote paths', () => {
|
||||
expect(
|
||||
absoluteToStylesheet(
|
||||
'background-image: url(images/b.jpg);background: #aabbcc url(images/a.jpg) 50% 50% repeat;',
|
||||
href,
|
||||
),
|
||||
).to.equal(
|
||||
`background-image: url(http://localhost/css/images/b.jpg);` +
|
||||
`background: #aabbcc url(http://localhost/css/images/a.jpg) 50% 50% repeat;`,
|
||||
);
|
||||
});
|
||||
|
||||
it('can handle data url image', () => {
|
||||
expect(
|
||||
absoluteToStylesheet('url(data:image/gif;base64,ABC)', href),
|
||||
).to.equal('url(data:image/gif;base64,ABC)');
|
||||
expect(
|
||||
absoluteToStylesheet(
|
||||
'url(data:application/font-woff;base64,d09GMgABAAAAAAm)',
|
||||
href,
|
||||
),
|
||||
).to.equal('url(data:application/font-woff;base64,d09GMgABAAAAAAm)');
|
||||
});
|
||||
|
||||
it('preserves quotes around inline svgs with spaces', () => {
|
||||
expect(
|
||||
absoluteToStylesheet(
|
||||
"url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8'%3E%3Cpath fill='%2328a745' d='M3'/%3E%3C/svg%3E\")",
|
||||
href,
|
||||
),
|
||||
).to.equal(
|
||||
"url(\"data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8'%3E%3Cpath fill='%2328a745' d='M3'/%3E%3C/svg%3E\")",
|
||||
);
|
||||
expect(
|
||||
absoluteToStylesheet(
|
||||
'url(\'data:image/svg+xml;utf8,<svg width="28" height="32" viewBox="0 0 28 32" xmlns="http://www.w3.org/2000/svg"><path d="M27 14C28" fill="white"/></svg>\')',
|
||||
href,
|
||||
),
|
||||
).to.equal(
|
||||
'url(\'data:image/svg+xml;utf8,<svg width="28" height="32" viewBox="0 0 28 32" xmlns="http://www.w3.org/2000/svg"><path d="M27 14C28" fill="white"/></svg>\')',
|
||||
);
|
||||
expect(
|
||||
absoluteToStylesheet(
|
||||
'url("data:image/svg+xml;utf8,<svg width=\"28\" height=\"32\" viewBox=\"0 0 28 32\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M27 14C28\" fill=\"white\"/></svg>")',
|
||||
href,
|
||||
),
|
||||
).to.equal(
|
||||
'url("data:image/svg+xml;utf8,<svg width=\"28\" height=\"32\" viewBox=\"0 0 28 32\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M27 14C28\" fill=\"white\"/></svg>")',
|
||||
);
|
||||
});
|
||||
it('can handle empty path', () => {
|
||||
expect(absoluteToStylesheet(`url('')`, href)).to.equal(`url('')`);
|
||||
});
|
||||
});
|
||||
|
||||
describe('isBlockedElement()', () => {
|
||||
const subject = (html: string, opt: any = {}) =>
|
||||
_isBlockedElement(render(html), 'rr-block', opt.blockSelector);
|
||||
|
||||
const render = (html: string): HTMLElement =>
|
||||
JSDOM.fragment(html).querySelector('div')!;
|
||||
|
||||
it('can handle empty elements', () => {
|
||||
expect(subject('<div />')).to.equal(false);
|
||||
});
|
||||
|
||||
it('blocks prohibited className', () => {
|
||||
expect(subject('<div class="foo rr-block bar" />')).to.equal(true);
|
||||
});
|
||||
|
||||
it('does not block random data selector', () => {
|
||||
expect(subject('<div data-rr-block />')).to.equal(false);
|
||||
});
|
||||
|
||||
it('blocks blocked selector', () => {
|
||||
expect(
|
||||
subject('<div data-rr-block />', { blockSelector: '[data-rr-block]' }),
|
||||
).to.equal(true);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user