Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions redbot/assets/red_style.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion redbot/assets/red_style.css.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion redbot/assets/style.css

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions redbot/webui/handlers/run_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,8 +392,8 @@ def render_form(

# Add submit button
form_parts.append(
f'<input type="submit" value="{escape(link_text)}" '
f'class="post_link {css_class}" title="{title}" />'
f'<button type="submit" class="post_link {css_class}" title="{title}">'
f"{escape(link_text)}</button>"
)
form_parts.append("</form>")

Expand Down
5 changes: 2 additions & 3 deletions src/scss/red_layout.scss
Original file line number Diff line number Diff line change
Expand Up @@ -138,13 +138,12 @@ form.link {
display: inline;
}

form.link input[type='submit'] {
form.link button {
border: none;
padding: 0;
background: none;
cursor: pointer;
font-family: inherit;
font-size: inherit;
font: inherit;
color: red_vars.$link_colour;
text-decoration: underline;
text-align: left;
Expand Down
7 changes: 7 additions & 0 deletions src/scss/red_response.scss
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@
.post_link {
color: red_vars.$link_in_box_colour;
}

// A button doesn't fold with the surrounding text unless told to.
.post_link {
white-space: normal;
overflow-wrap: anywhere;
text-indent: 0;
}
}

.nonfinal_response {
Expand Down
4 changes: 4 additions & 0 deletions test/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ def test_handler(exchange):
if uri == "/img.png":
content = b"\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\x01\x00\x00\x00\x01\x08\x06\x00\x00\x00\x1f\x15\xc4\x89\x00\x00\x00\nIDATx\x9cc\x00\x01\x00\x00\x05\x00\x01\r\n-\xb4\x00\x00\x00\x00IEND\xaeB`\x82"
resp_hdrs[b"Content-Type"] = b"image/png"
elif uri == "/redirect-long":
status = b"302"
phrase = b"Found"
resp_hdrs[b"Location"] = b"http://127.0.0.1:8001/sorry/index?continue=http://127.0.0.1:8001/&q=" + b"a" * 150
elif method not in ["GET", "HEAD"]:
status = b"501"
phrase = b"Not Implemented"
Expand Down
1 change: 1 addition & 0 deletions test/test_html_escaping.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ def test_location_is_escaped_once(self):
formatter.finish_output()
page = "".join(out)
self.assertIn('value="http://a.example/?x=1&amp;y=2&amp;z=&#39;&#34;&lt;&gt;"', page)
self.assertIn(">http://a.example/?x=1&amp;y=2&amp;z=&#39;&#34;&lt;&gt;</button>", page)
self.assertNotIn("&amp;amp;", page)
self.assertNotIn("&amp;#", page)
self.assertNotIn("&amp;lt;", page)
Expand Down
4 changes: 2 additions & 2 deletions test/test_table_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def render(self) -> str:
def test_redirect_links_to_its_location(self):
page = self.render()
self.assertIn('name="uri" value="http://a.example/new.js"', page)
self.assertIn('value="301"', page) # the link's label
self.assertIn(">301</button>", page) # the link's label

def test_error_statuses_are_marked_bad(self):
page = self.render()
Expand Down Expand Up @@ -129,7 +129,7 @@ def test_useless_locations_get_no_link(self):
for location in ["", " "]:
with self.subTest(location=location):
page = self.render("http://other.example/sub/mv", location)
self.assertNotIn('value="301"', page) # shown, but not as a link
self.assertNotIn(">301</button>", page) # shown, but not as a link
self.assertIn("<td>301</td>", page)


Expand Down
13 changes: 12 additions & 1 deletion test/test_webui.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,20 @@ def tearDown(self):
self.context.close()

def test_multi(self):
self.page.click('input[value="check embedded"]')
self.page.click('button:has-text("check embedded")')
self.check_complete()

def test_long_location_folds(self):
self.page.fill("#uri", self.test_uri + "redirect-long")
self.page.press("#uri", "Enter")
self.check_complete()
link = self.page.locator("#response li[data-name='location'] button.post_link")
box = self.page.locator("#response")
link_box = link.bounding_box()
outer_box = box.bounding_box()
self.assertLessEqual(link_box["x"] + link_box["width"], outer_box["x"] + outer_box["width"])
self.assertGreater(link_box["height"], 2 * 14) # more than one line

def test_request_header(self):
self.page.click("#add_req_hdr")
self.page.wait_for_selector(".hdr_name select")
Expand Down
Loading