This commit is contained in:
Josh at WLTechBlog
2025-10-02 11:59:06 -05:00
parent 2817b8a049
commit 2461d7f6f2
4 changed files with 746 additions and 12 deletions

View File

@@ -8669,9 +8669,10 @@ func (d *Daemon) runAxeCore(tabID string, options map[string]interface{}, timeou
optionsJSON = string(optionsBytes)
}
// Run axe tests
runCode := fmt.Sprintf(`() => {
return axe.run(%s);
// Run axe tests - axe.run() returns a Promise, so we need to await it and stringify
runCode := fmt.Sprintf(`async () => {
const results = await axe.run(%s);
return JSON.stringify(results);
}`, optionsJSON)
var jsResult *proto.RuntimeRemoteObject
@@ -8709,7 +8710,7 @@ func (d *Daemon) runAxeCore(tabID string, options map[string]interface{}, timeou
}
// Parse the results
resultsJSON := jsResult.Value.String()
resultsJSON := jsResult.Value.Str()
var results AxeResults
err = json.Unmarshal([]byte(resultsJSON), &results)
if err != nil {
@@ -8888,7 +8889,7 @@ func (d *Daemon) checkContrast(tabID string, selector string, timeout int) (*Con
}
});
return results;
return JSON.stringify(results);
}`, selector, selector, selector, selector)
var jsResult *proto.RuntimeRemoteObject
@@ -8926,7 +8927,7 @@ func (d *Daemon) checkContrast(tabID string, selector string, timeout int) (*Con
}
// Parse the results
resultsJSON := jsResult.Value.String()
resultsJSON := jsResult.Value.Str()
var elements []ContrastCheckElement
err = json.Unmarshal([]byte(resultsJSON), &elements)
if err != nil {
@@ -9167,7 +9168,7 @@ func (d *Daemon) testKeyboardNavigation(tabID string, timeout int) (*KeyboardTes
// Note: This is a simplified check, real trap detection is complex
}
return results;
return JSON.stringify(results);
}`
var jsResult *proto.RuntimeRemoteObject
@@ -9205,7 +9206,7 @@ func (d *Daemon) testKeyboardNavigation(tabID string, timeout int) (*KeyboardTes
}
// Parse the results
resultsJSON := jsResult.Value.String()
resultsJSON := jsResult.Value.Str()
var result KeyboardTestResult
err = json.Unmarshal([]byte(resultsJSON), &result)
if err != nil {
@@ -9371,6 +9372,7 @@ func (d *Daemon) testZoom(tabID string, zoomLevels []float64, timeout int) (*Zoo
text_readable: textReadable,
min_font_size: minFontSize
};
return JSON.stringify(result);
}`
var jsResult *proto.RuntimeRemoteObject
@@ -9427,7 +9429,7 @@ func (d *Daemon) testZoom(tabID string, zoomLevels []float64, timeout int) (*Zoo
// Parse the results
var zoomTest ZoomLevelTest
err = json.Unmarshal([]byte(jsResult.Value.String()), &zoomTest)
err = json.Unmarshal([]byte(jsResult.Value.Str()), &zoomTest)
if err != nil {
result.Issues = append(result.Issues, ZoomTestIssue{
ZoomLevel: zoom,
@@ -9618,7 +9620,7 @@ func (d *Daemon) testReflow(tabID string, widths []int, timeout int) (*ReflowTes
// (content width should not significantly exceed viewport width)
const responsiveLayout = contentWidth <= window.innerWidth + 20;
return {
return JSON.stringify({
width: window.innerWidth,
height: window.innerHeight,
has_horizontal_scroll: hasHorizontalScroll,
@@ -9627,7 +9629,7 @@ func (d *Daemon) testReflow(tabID string, widths []int, timeout int) (*ReflowTes
visible_elements: visibleCount,
overflowing_elements: overflowingCount,
responsive_layout: responsiveLayout
};
});
}`
var jsResult *proto.RuntimeRemoteObject
@@ -9684,7 +9686,7 @@ func (d *Daemon) testReflow(tabID string, widths []int, timeout int) (*ReflowTes
// Parse the results
var breakpoint ReflowBreakpoint
err = json.Unmarshal([]byte(jsResult.Value.String()), &breakpoint)
err = json.Unmarshal([]byte(jsResult.Value.Str()), &breakpoint)
if err != nil {
result.Issues = append(result.Issues, ReflowTestIssue{
Width: width,