Skip to content

Commit 7d3e3a0

Browse files
authored
Merge pull request #19 from Webperf-se/test
Added regression test
2 parents fb4e01b + ee2af3c commit 7d3e3a0

File tree

3 files changed

+12
-20
lines changed

3 files changed

+12
-20
lines changed

lib/harAnalyzer.js

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export class HarAnalyzer {
2222
const libFolder = fileURLToPath(new URL('..', import.meta.url));
2323
this.pluginFolder = path.resolve(libFolder, '..');
2424
}
25-
transform2SimplifiedData(harData, url, group) {
25+
transform2SimplifiedData(harData, url) {
2626
const data = {
2727
'url': url,
2828
'security-rules': this.configSecurity,
@@ -82,20 +82,6 @@ export class HarAnalyzer {
8282
data['script-elements'].push(styleElementObj);
8383
}
8484
});
85-
86-
// Extract style="" attributes from HTML content
87-
// const elementsWithStyleAttr = dom.window.document.querySelectorAll('[style]');
88-
// elementsWithStyleAttr.forEach((element, index) => {
89-
// const styleAttrContent = element.getAttribute('style');
90-
// const styleAttrObj = {
91-
// 'url': htmlObj.url,
92-
// // Wrap the style attribute content in a dummy #id rule
93-
// 'content': `#dummy-style-attribute-id { ${styleAttrContent} }`,
94-
// 'index': htmlObj.index
95-
// };
96-
// data['all-styles'].push(styleAttrObj);
97-
// data['style-attributes'].push(styleAttrObj);
98-
// });
9985
}
10086

10187
return data;
@@ -175,7 +161,7 @@ export class HarAnalyzer {
175161
this.groups[group] = {};
176162
}
177163

178-
const analyzedData = this.transform2SimplifiedData(harData, url, group);
164+
const analyzedData = this.transform2SimplifiedData(harData, url);
179165
if (!('analyzedData' in this.groups[group])) {
180166
this.groups[group]['analyzedData'] = []
181167
}

lib/index.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export default class JavascriptPlugin extends SitespeedioPlugin {
2020
this.harAnalyzer = new HarAnalyzer();
2121
const libFolder = fileURLToPath(new URL('..', import.meta.url));
2222
this.pluginFolder = path.resolve(libFolder);
23+
this.options = options;
2324

2425
this.pug = await fsp.readFile(
2526
path.resolve(this.pluginFolder, 'pug', 'index.pug'),
@@ -83,7 +84,7 @@ export default class JavascriptPlugin extends SitespeedioPlugin {
8384
}
8485
}
8586
}
86-
close(options, errors) {
87-
// Cleanup if necessary
88-
}
87+
// close(options, errors) {
88+
// // Cleanup if necessary
89+
// }
8990
}

package.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,10 @@
4444
"eslint-config-prettier": "10.1.1",
4545
"eslint-plugin-prettier": "5.2.5",
4646
"eslint-plugin-unicorn": "58.0.0",
47-
"prettier": "3.5.3"
47+
"prettier": "3.5.3",
48+
"serve": "14.2.4",
49+
"serve-handler": "6.1.6",
50+
"typescript": "5.7.2"
4851
},
4952
"dependencies": {
5053
"jsdom": "26.0.0",
@@ -55,6 +58,8 @@
5558
},
5659
"scripts": {
5760
"test": "ava",
61+
"start-server": "serve test/data/",
62+
"stop-server": "sudo pkill serve",
5863
"lint": "eslint .",
5964
"lint:fix": "eslint . --fix",
6065
"eslint-check": "eslint --print-config .eslintrc.js | eslint-config-prettier-check"

0 commit comments

Comments
 (0)