From 1ebf0d9c72de95bd1de677f2e7234cea626e3fb7 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 23 May 2022 23:06:36 +0200 Subject: [PATCH 1/4] Allow to click on toggle text to update it --- src/librustdoc/html/static/css/rustdoc.css | 24 ------------- src/librustdoc/html/static/css/settings.css | 40 +++++++++++++++++---- src/librustdoc/html/static/js/settings.js | 11 +++--- 3 files changed, 39 insertions(+), 36 deletions(-) diff --git a/src/librustdoc/html/static/css/rustdoc.css b/src/librustdoc/html/static/css/rustdoc.css index 4eb8029ee2d..d0229bdb5f2 100644 --- a/src/librustdoc/html/static/css/rustdoc.css +++ b/src/librustdoc/html/static/css/rustdoc.css @@ -1415,30 +1415,6 @@ pre.rust { #settings-menu.rotate > a img { animation: rotating 2s linear infinite; } -#settings-menu #settings { - position: absolute; - right: 0; - z-index: 1; - display: block; - margin-top: 7px; - border-radius: 3px; - border: 1px solid; -} -#settings-menu #settings .setting-line { - margin: 0.6em; -} -/* This rule is to draw the little arrow connecting the settings menu to the gear icon. */ -#settings-menu #settings::before { - content: ''; - position: absolute; - right: 11px; - border: solid; - border-width: 1px 1px 0 0; - display: inline-block; - padding: 4px; - transform: rotate(-45deg); - top: -5px; -} #help-button { font-family: "Fira Sans", Arial, sans-serif; diff --git a/src/librustdoc/html/static/css/settings.css b/src/librustdoc/html/static/css/settings.css index 07588748ad6..c69ff04236d 100644 --- a/src/librustdoc/html/static/css/settings.css +++ b/src/librustdoc/html/static/css/settings.css @@ -46,9 +46,12 @@ .toggle { position: relative; display: inline-block; - width: 45px; + width: 100%; height: 27px; margin-right: 20px; + display: flex; + align-items: center; + cursor: pointer; } .toggle input { @@ -57,12 +60,12 @@ } .slider { - position: absolute; + position: relative; + width: 45px; + display: block; + height: 28px; + margin-right: 20px; cursor: pointer; - top: 0; - left: 0; - right: 0; - bottom: 0; background-color: #ccc; transition: .3s; } @@ -95,3 +98,28 @@ input:checked + .slider:before { width: 100%; display: block; } + +div#settings { + position: absolute; + right: 0; + z-index: 1; + display: block; + margin-top: 7px; + border-radius: 3px; + border: 1px solid; +} +#settings .setting-line { + margin: 1.2em 0.6em; +} +/* This rule is to draw the little arrow connecting the settings menu to the gear icon. */ +div#settings::before { + content: ''; + position: absolute; + right: 11px; + border: solid; + border-width: 1px 1px 0 0; + display: inline-block; + padding: 4px; + transform: rotate(-45deg); + top: -5px; +} diff --git a/src/librustdoc/html/static/js/settings.js b/src/librustdoc/html/static/js/settings.js index 8770cc3f3b1..6746783717f 100644 --- a/src/librustdoc/html/static/js/settings.js +++ b/src/librustdoc/html/static/js/settings.js @@ -130,12 +130,11 @@ } else { // This is a toggle. const checked = setting["default"] === true ? " checked" : ""; - output += ` - -
${setting_name}
`; + output += ``; } output += ""; } From fca1007ed31af41dfcc8e8c13a2c0676cfb28ace Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 23 May 2022 16:53:44 +0200 Subject: [PATCH 2/4] Add GUI test for click on setting text --- src/test/rustdoc-gui/settings.goml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/test/rustdoc-gui/settings.goml b/src/test/rustdoc-gui/settings.goml index 9a9c45a9b7f..1b2d1e31f52 100644 --- a/src/test/rustdoc-gui/settings.goml +++ b/src/test/rustdoc-gui/settings.goml @@ -34,7 +34,7 @@ wait-for: "#settings" // We check that the "Use system theme" is disabled. assert-property: ("#use-system-theme", {"checked": "false"}) -assert: "//*[@class='setting-line']/*[text()='Use system theme']" +assert: "//*[@class='setting-line']//span[text()='Use system theme']" // Meaning that only the "theme" menu is showing up. assert: ".setting-line:not(.hidden) #theme" assert: ".setting-line.hidden #preferred-dark-theme" @@ -55,7 +55,13 @@ assert: ".setting-line.hidden #theme" assert-text: ("#preferred-dark-theme .setting-name", "Preferred dark theme") assert-text: ("#preferred-light-theme .setting-name", "Preferred light theme") +// We now check that clicking on the "sliders"' text is like clicking on the slider. +// To test it, we use the "Disable keyboard shortcuts". +local-storage: {"rustdoc-disable-shortcuts": "false"} +click: ".setting-line:last-child .toggle .label" +assert-local-storage: {"rustdoc-disable-shortcuts": "true"} + // Now we go to the settings page to check that the CSS is loaded as expected. goto: file://|DOC_PATH|/settings.html wait-for: "#settings" -assert-css: (".setting-line .toggle", {"width": "45px", "margin-right": "20px"}) +assert-css: (".setting-line .toggle .slider", {"width": "45px", "margin-right": "20px"}) From cee58cb6b9a53f9c3e2a096961ffe55864be8210 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Tue, 24 May 2022 13:23:58 +0200 Subject: [PATCH 3/4] Allow to pass more arguments to tester.js --- src/tools/rustdoc-gui/tester.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/tools/rustdoc-gui/tester.js b/src/tools/rustdoc-gui/tester.js index 8532410a1bf..4599e12de5f 100644 --- a/src/tools/rustdoc-gui/tester.js +++ b/src/tools/rustdoc-gui/tester.js @@ -19,6 +19,7 @@ function showHelp() { console.log(" --help : show this message then quit"); console.log(" --tests-folder [PATH] : location of the .GOML tests folder"); console.log(" --jobs [NUMBER] : number of threads to run tests on"); + console.log(" --executable-path [PATH] : path of the browser's executable to be used"); } function isNumeric(s) { @@ -34,6 +35,8 @@ function parseOptions(args) { "show_text": false, "no_headless": false, "jobs": -1, + "executable_path": null, + "no_sandbox": false, }; var correspondances = { "--doc-folder": "doc_folder", @@ -41,13 +44,16 @@ function parseOptions(args) { "--debug": "debug", "--show-text": "show_text", "--no-headless": "no_headless", + "--executable-path": "executable_path", + "--no-sandbox": "no_sandbox", }; for (var i = 0; i < args.length; ++i) { if (args[i] === "--doc-folder" || args[i] === "--tests-folder" || args[i] === "--file" - || args[i] === "--jobs") { + || args[i] === "--jobs" + || args[i] === "--executable-path") { i += 1; if (i >= args.length) { console.log("Missing argument after `" + args[i - 1] + "` option."); @@ -68,6 +74,9 @@ function parseOptions(args) { } else if (args[i] === "--help") { showHelp(); process.exit(0); + } else if (args[i] === "--no-sandbox") { + console.log("`--no-sandbox` is being used. Be very careful!"); + opts[correspondances[args[i]]] = true; } else if (correspondances[args[i]]) { opts[correspondances[args[i]]] = true; } else { @@ -147,10 +156,17 @@ async function main(argv) { if (opts["show_text"]) { args.push("--show-text"); } + if (opts["no_sandbox"]) { + args.push("--no-sandbox"); + } if (opts["no_headless"]) { args.push("--no-headless"); headless = false; } + if (opts["executable_path"] !== null) { + args.push("--executable-path"); + args.push(opts["executable_path"]); + } options.parseArguments(args); } catch (error) { console.error(`invalid argument: ${error}`); From f4f14f66711756e67bbc252b9e14546c771fe508 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Tue, 24 May 2022 15:41:24 +0200 Subject: [PATCH 4/4] Update browser-ui-test version to 0.9.5 --- .../docker/host-x86_64/x86_64-gnu-tools/browser-ui-test.version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ci/docker/host-x86_64/x86_64-gnu-tools/browser-ui-test.version b/src/ci/docker/host-x86_64/x86_64-gnu-tools/browser-ui-test.version index b3ec1638fda..03834411d15 100644 --- a/src/ci/docker/host-x86_64/x86_64-gnu-tools/browser-ui-test.version +++ b/src/ci/docker/host-x86_64/x86_64-gnu-tools/browser-ui-test.version @@ -1 +1 @@ -0.9.3 \ No newline at end of file +0.9.5 \ No newline at end of file