| 1 | //go:build browser |
| 2 | |
| 3 | package movementtest |
| 4 | |
| 5 | import ( |
| 6 | "fmt" |
| 7 | "testing" |
| 8 | |
| 9 | "github.com/chromedp/chromedp" |
| 10 | ) |
| 11 | |
| 12 | // Every field on the form is styled the same way, checked in a real browser |
| 13 | // against computed style rather than by reading the stylesheet. |
| 14 | // |
| 15 | // This exists because the name field shipped unstyled: the rule was bound to |
| 16 | // input[type="email"], so the first text input added to the form fell |
| 17 | // straight through to the browser's rounded default and nothing noticed. A |
| 18 | // selector that names one input type is a trap for the next field somebody |
| 19 | // adds, and only the browser can say what actually applied. |
| 20 | func TestEveryFieldIsRuledNotBoxed(t *testing.T) { |
| 21 | rig := powRig(t) |
| 22 | rig.Run(chromedp.Navigate(rig.Origin + "/uneasy")) |
| 23 | |
| 24 | for _, sel := range []string{"#name", "#email", "#background"} { |
| 25 | var radius, bottomWidth string |
| 26 | rig.Run( |
| 27 | chromedp.Evaluate(fmt.Sprintf( |
| 28 | `getComputedStyle(document.querySelector(%q)).borderTopLeftRadius`, sel), |
| 29 | &radius), |
| 30 | chromedp.Evaluate(fmt.Sprintf( |
| 31 | `getComputedStyle(document.querySelector(%q)).borderBottomWidth`, sel), |
| 32 | &bottomWidth), |
| 33 | ) |
| 34 | if radius != "0px" { |
| 35 | t.Errorf("%s has a corner radius of %s; this world has no rounded corners", |
| 36 | sel, radius) |
| 37 | } |
| 38 | if bottomWidth != "2px" { |
| 39 | t.Errorf("%s has a %s bottom rule; the fields are ruled underlines", |
| 40 | sel, bottomWidth) |
| 41 | } |
| 42 | } |
| 43 | } |
| 44 | |