v0.32.0 0617278

scale_probe_test.go RawHistoryFolder

1package cef
2
3import (
4	"strings"
5	"testing"
6)
7
8func TestCEFScaleProbeScriptCapturesViewportMetrics(t *testing.T) {
9	for _, want := range []string{
10		"window.devicePixelRatio",
11		"window.innerWidth",
12		"document.documentElement.clientWidth",
13		"window.visualViewport",
14		"width:100px;height:100px",
15		"[SCALE-PROBE]",
16	} {
17		if !strings.Contains(cefScaleProbeScript, want) {
18			t.Fatalf("cefScaleProbeScript missing %q", want)
19		}
20	}
21}
22
23func TestShouldRunCEFScaleProbeSkipsIntermediateHTTPStatusZero(t *testing.T) {
24	if shouldRunCEFScaleProbe("https://example.com", 0) {
25		t.Fatal("probe should skip intermediate HTTP status 0 for http URLs")
26	}
27	if !shouldRunCEFScaleProbe("https://example.com", 200) {
28		t.Fatal("probe should run for successful HTTP load")
29	}
30	if shouldRunCEFScaleProbe("about:blank", 200) {
31		t.Fatal("probe should skip about:blank")
32	}
33	if !shouldRunCEFScaleProbe("file:///tmp/probe.html", 0) {
34		t.Fatal("probe should allow non-HTTP status 0 loads")
35	}
36}
37
38func TestCEFScaleProbeSnapshotNormalizesMissingBridge(t *testing.T) {
39	s := cefScaleProbeSnapshot(nil)
40	if s.SurfaceWidth != 1 || s.SurfaceHeight != 1 {
41		t.Fatalf("surface size = %dx%d, want 1x1", s.SurfaceWidth, s.SurfaceHeight)
42	}
43	if s.SurfaceScale != 1 || s.PageZoomCompensation != 1 {
44		t.Fatalf("scales = surface %v compensation %v, want 1/1", s.SurfaceScale, s.PageZoomCompensation)
45	}
46	if s.UserZoom != 1 || s.InternalCEFFactor != 1 {
47		t.Fatalf("zoom = user %v internal %v, want 1/1", s.UserZoom, s.InternalCEFFactor)
48	}
49}
50
51func TestCEFScaleProbeSnapshotDerivesInternalFactorFromContract(t *testing.T) {
52	wv := &WebView{zoomCompensation: zoomCompensationStub{compensation: 1.75}}
53	wv.zoomFactor.Store(1.3)
54
55	s := cefScaleProbeSnapshot(wv)
56
57	if s.UserZoom != 1.3 {
58		t.Fatalf("user zoom = %v, want 1.3", s.UserZoom)
59	}
60	if s.PageZoomCompensation != 1.75 {
61		t.Fatalf("compensation = %v, want 1.75", s.PageZoomCompensation)
62	}
63	if s.InternalCEFFactor != 2.275 {
64		t.Fatalf("internal CEF factor = %v, want user zoom x compensation = 2.275", s.InternalCEFFactor)
65	}
66	fields := s.logFields()
67	if _, ok := fields["page_zoom_compensation"]; !ok {
68		t.Fatalf("probe fields %v missing page_zoom_compensation", fields)
69	}
70	if _, ok := fields["osr_backing_scale"]; ok {
71		t.Fatalf("probe fields %v must not carry a separate backing-scale formula", fields)
72	}
73}

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 8

Tags 42

↑↓ moveenter openesc close