Bug 1464118 [wpt PR 11143] - Inline testharness.css into testharness.js for better performance, a=testonly
authorSimon Pieters <zcorpan@gmail.com>
Wed, 06 Jun 2018 14:31:10 +0000
changeset 422132 46ca86af6962ec2a4e5c86a23a769ee486e54fc1
parent 422131 3fcd34d771caa4db716c15e10024ed2e3af23633
child 422133 59d0ee801ffad99e17a7e96d70ffa5e3020937c5
push id34122
push userebalazs@mozilla.com
push dateMon, 11 Jun 2018 09:37:00 +0000
treeherdermozilla-central@9941eb8c3b29 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1464118, 11143
milestone62.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1464118 [wpt PR 11143] - Inline testharness.css into testharness.js for better performance, a=testonly Automatic update from web-platform-testsInline testharness.css into testharness.js for better performance Loading the stylesheet at the same time as inserting the results table causes the table to be rendered twice in different layout modes, which takes a long time for very big tables. -- wpt-commits: 228b5b229c1ed8b738fc65955d85823a4890aa3d wpt-pr: 11143
testing/web-platform/tests/resources/testharness.css
testing/web-platform/tests/resources/testharness.js
deleted file mode 100644
--- a/testing/web-platform/tests/resources/testharness.css
+++ /dev/null
@@ -1,102 +0,0 @@
-html {
-    font-family:DejaVu Sans, Bitstream Vera Sans, Arial, Sans;
-}
-
-#log .warning,
-#log .warning a {
-  color: black;
-  background: yellow;
-}
-
-#log .error,
-#log .error a {
-  color: white;
-  background: red;
-}
-
-section#summary {
-    margin-bottom:1em;
-}
-
-table#results {
-    border-collapse:collapse;
-    table-layout:fixed;
-    width:100%;
-}
-
-table#results th:first-child,
-table#results td:first-child {
-    width:4em;
-}
-
-table#results th:last-child,
-table#results td:last-child {
-    width:50%;
-}
-
-table#results.assertions th:last-child,
-table#results.assertions td:last-child {
-    width:35%;
-}
-
-table#results th {
-    padding:0;
-    padding-bottom:0.5em;
-    border-bottom:medium solid black;
-}
-
-table#results td {
-    padding:1em;
-    padding-bottom:0.5em;
-    border-bottom:thin solid black;
-}
-
-tr.pass > td:first-child {
-    color:green;
-}
-
-tr.fail > td:first-child {
-    color:red;
-}
-
-tr.timeout > td:first-child {
-    color:red;
-}
-
-tr.notrun > td:first-child {
-    color:blue;
-}
-
-.pass > td:first-child, .fail > td:first-child, .timeout > td:first-child, .notrun > td:first-child {
-    font-variant:small-caps;
-}
-
-table#results span {
-    display:block;
-}
-
-table#results span.expected {
-    font-family:DejaVu Sans Mono, Bitstream Vera Sans Mono, Monospace;
-    white-space:pre;
-}
-
-table#results span.actual {
-    font-family:DejaVu Sans Mono, Bitstream Vera Sans Mono, Monospace;
-    white-space:pre;
-}
-
-span.ok {
-    color:green;
-}
-
-tr.error {
-    color:red;
-}
-
-span.timeout {
-    color:red;
-}
-
-span.ok, span.timeout, span.error {
-    font-variant:small-caps;
-}
\ No newline at end of file
--- a/testing/web-platform/tests/resources/testharness.js
+++ b/testing/web-platform/tests/resources/testharness.js
@@ -2398,25 +2398,21 @@ policies and contribution forms [3].
             return;
         }
         var output_document = this.output_document;
 
         while (log.lastChild) {
             log.removeChild(log.lastChild);
         }
 
-        var harness_url = get_harness_url();
-        if (harness_url !== undefined) {
-            var stylesheet = output_document.createElementNS(xhtml_ns, "link");
-            stylesheet.setAttribute("rel", "stylesheet");
-            stylesheet.setAttribute("href", harness_url + "testharness.css");
-            var heads = output_document.getElementsByTagName("head");
-            if (heads.length) {
-                heads[0].appendChild(stylesheet);
-            }
+        var stylesheet = output_document.createElementNS(xhtml_ns, "style");
+        stylesheet.textContent = stylesheetContent;
+        var heads = output_document.getElementsByTagName("head");
+        if (heads.length) {
+            heads[0].appendChild(stylesheet);
         }
 
         var status_text_harness = {};
         status_text_harness[harness_status.OK] = "OK";
         status_text_harness[harness_status.ERROR] = "Error";
         status_text_harness[harness_status.TIMEOUT] = "Timeout";
 
         var status_text = {};
@@ -2916,26 +2912,16 @@ policies and contribution forms [3].
             var matches = src && src.match(/^(.*\/|)testharness\.js$/);
             if (matches) {
                 return src;
             }
         }
         return undefined;
     }
 
-    /** Returns the URL path at which the files for testharness.js are assumed to reside (e.g., '/resources/').
-        The path is derived from inspecting the 'src' of the <script> tag that included 'testharness.js'. */
-    function get_harness_url()
-    {
-        var script_url = get_script_url();
-
-        // Exclude the 'testharness.js' file from the returned path, but '+ 1' to include the trailing slash.
-        return script_url ? script_url.slice(0, script_url.lastIndexOf('/') + 1) : undefined;
-    }
-
     function supports_post_message(w)
     {
         var supports;
         var type;
         // Given IE implements postMessage across nested iframes but not across
         // windows or tabs, you can't infer cross-origin communication from the presence
         // of postMessage on the current window object only.
         //
@@ -3004,10 +2990,118 @@ policies and contribution forms [3].
         };
 
         addEventListener("error", error_handler, false);
         addEventListener("unhandledrejection", function(e){ error_handler(e.reason); }, false);
     }
 
     test_environment.on_tests_ready();
 
+    /**
+     * Stylesheet
+     */
+     var stylesheetContent = `
+html {
+    font-family:DejaVu Sans, Bitstream Vera Sans, Arial, Sans;
+}
+
+#log .warning,
+#log .warning a {
+  color: black;
+  background: yellow;
+}
+
+#log .error,
+#log .error a {
+  color: white;
+  background: red;
+}
+
+section#summary {
+    margin-bottom:1em;
+}
+
+table#results {
+    border-collapse:collapse;
+    table-layout:fixed;
+    width:100%;
+}
+
+table#results th:first-child,
+table#results td:first-child {
+    width:4em;
+}
+
+table#results th:last-child,
+table#results td:last-child {
+    width:50%;
+}
+
+table#results.assertions th:last-child,
+table#results.assertions td:last-child {
+    width:35%;
+}
+
+table#results th {
+    padding:0;
+    padding-bottom:0.5em;
+    border-bottom:medium solid black;
+}
+
+table#results td {
+    padding:1em;
+    padding-bottom:0.5em;
+    border-bottom:thin solid black;
+}
+
+tr.pass > td:first-child {
+    color:green;
+}
+
+tr.fail > td:first-child {
+    color:red;
+}
+
+tr.timeout > td:first-child {
+    color:red;
+}
+
+tr.notrun > td:first-child {
+    color:blue;
+}
+
+.pass > td:first-child, .fail > td:first-child, .timeout > td:first-child, .notrun > td:first-child {
+    font-variant:small-caps;
+}
+
+table#results span {
+    display:block;
+}
+
+table#results span.expected {
+    font-family:DejaVu Sans Mono, Bitstream Vera Sans Mono, Monospace;
+    white-space:pre;
+}
+
+table#results span.actual {
+    font-family:DejaVu Sans Mono, Bitstream Vera Sans Mono, Monospace;
+    white-space:pre;
+}
+
+span.ok {
+    color:green;
+}
+
+tr.error {
+    color:red;
+}
+
+span.timeout {
+    color:red;
+}
+
+span.ok, span.timeout, span.error {
+    font-variant:small-caps;
+}
+`;
+
 })(this);
 // vim: set expandtab shiftwidth=4 tabstop=4: