Bug 1604034 - Make a11y.js a content frame script. r=surkov
authorMasatoshi Kimura <VYV03354@nifty.ne.jp>
Wed, 08 Jan 2020 23:11:45 +0000
changeset 509506 6616b2557469e57914aa0ccdc6556be70dd2d970
parent 509505 799dde1e333cc5788ccb78f81e7d09efb7370c57
child 509507 e1404ca1c50d0d86e7f0d1f57972432bcc622c7c
push id104667
push userVYV03354@nifty.ne.jp
push dateThu, 09 Jan 2020 09:56:17 +0000
treeherderautoland@e1404ca1c50d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssurkov
bugs1604034
milestone74.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 1604034 - Make a11y.js a content frame script. r=surkov Differential Revision: https://phabricator.services.mozilla.com/D57242
testing/talos/talos/pageloader/chrome/a11y.js
testing/talos/talos/pageloader/chrome/pageloader.js
testing/talos/talos/run_tests.py
testing/talos/talos/test.py
testing/talos/talos/tests/a11y/a11y.js
testing/talos/talos/tests/a11y/dhtml.html
testing/talos/talos/tests/a11y/tablemutation.html
rename from testing/talos/talos/tests/a11y/a11y.js
rename to testing/talos/talos/pageloader/chrome/a11y.js
--- a/testing/talos/talos/tests/a11y/a11y.js
+++ b/testing/talos/talos/pageloader/chrome/a11y.js
@@ -1,56 +1,60 @@
-/* globals gAccService:true, nsIAccessible:true */
-gAccService = 0;
+(function() {
+  let gAccService = 0;
 
-// Make sure not to touch Components before potentially invoking enablePrivilege,
-// because otherwise it won't be there.
-netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
-nsIAccessible = Ci.nsIAccessible;
+  function initAccessibility() {
+    if (!gAccService) {
+      var service = Cc["@mozilla.org/accessibilityService;1"];
+      if (service) {
+        // fails if build lacks accessibility module
+        gAccService = Cc["@mozilla.org/accessibilityService;1"].getService(
+          Ci.nsIAccessibilityService
+        );
+      }
+    }
+    return !!gAccService;
+  }
 
-function initAccessibility() {
-  netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
-  if (!gAccService) {
-    var service = Cc["@mozilla.org/accessibilityService;1"];
-    if (service) {
-      // fails if build lacks accessibility module
-      gAccService = Cc["@mozilla.org/accessibilityService;1"].getService(
-        Ci.nsIAccessibilityService
-      );
+  function getAccessible(aNode) {
+    try {
+      return gAccService.getAccessibleFor(aNode);
+    } catch (e) {}
+
+    return null;
+  }
+
+  function ensureAccessibleTreeForNode(aNode) {
+    var acc = getAccessible(aNode);
+
+    ensureAccessibleTreeForAccessible(acc);
+  }
+
+  function ensureAccessibleTreeForAccessible(aAccessible) {
+    var child = aAccessible.firstChild;
+    while (child) {
+      ensureAccessibleTreeForAccessible(child);
+      try {
+        child = child.nextSibling;
+      } catch (e) {
+        child = null;
+      }
     }
   }
-  return gAccService;
-}
 
-function getAccessible(aNode) {
-  try {
-    return gAccService.getAccessibleFor(aNode);
-  } catch (e) {}
-
-  return null;
-}
-
-function ensureAccessibleTreeForNode(aNode) {
-  var acc = getAccessible(aNode);
-
-  ensureAccessibleTreeForAccessible(acc);
-}
+  // Walk accessible tree of the given identifier to ensure tree creation
+  function ensureAccessibleTreeForId(aID) {
+    var node = content.document.getElementById(aID);
+    if (!node) {
+      return;
+    }
+    ensureAccessibleTreeForNode(node);
+  }
 
-function ensureAccessibleTreeForAccessible(aAccessible) {
-  var child = aAccessible.firstChild;
-  while (child) {
-    ensureAccessibleTreeForAccessible(child);
-    try {
-      child = child.nextSibling;
-    } catch (e) {
-      child = null;
-    }
-  }
-}
-
-// Walk accessible tree of the given identifier to ensure tree creation
-function ensureAccessibleTreeForId(aID) {
-  var node = document.getElementById(aID);
-  if (!node) {
-    return;
-  }
-  ensureAccessibleTreeForNode(node);
-}
+  addEventListener("DOMContentLoaded", e => {
+    Cu.exportFunction(initAccessibility, content, {
+      defineAs: "initAccessibility",
+    });
+    Cu.exportFunction(ensureAccessibleTreeForId, content, {
+      defineAs: "ensureAccessibleTreeForId",
+    });
+  });
+})();
--- a/testing/talos/talos/pageloader/chrome/pageloader.js
+++ b/testing/talos/talos/pageloader/chrome/pageloader.js
@@ -44,16 +44,17 @@ var isPDFPaintPending = false;
 var useHero = false;
 var gPaintWindow = window;
 var gPaintListener = false;
 var loadNoCache = false;
 var scrollTest = false;
 var profilingInfo = false;
 var baseVsRef = false;
 var useBrowserChrome = false;
+var useA11y = false;
 
 var isIdleCallbackPending = false;
 
 // when TEST_DOES_OWN_TIMING, we need to store the time from the page as MozAfterPaint can be slower than pageload
 var gTime = -1;
 var gStartTime = -1;
 var gReference = -1;
 
@@ -141,16 +142,17 @@ function plInit() {
       false
     );
     useHero = Services.prefs.getBoolPref("talos.tphero", false);
     useFNBPaint = Services.prefs.getBoolPref("talos.fnbpaint", false);
     usePDFPaint = Services.prefs.getBoolPref("talos.pdfpaint", false);
     loadNoCache = Services.prefs.getBoolPref("talos.tploadnocache", false);
     scrollTest = Services.prefs.getBoolPref("talos.tpscrolltest", false);
     useBrowserChrome = Services.prefs.getBoolPref("talos.tpchrome", false);
+    useA11y = Services.prefs.getBoolPref("talos.a11y", false);
 
     // for pageloader tests the profiling info is found in an env variable
     // because it is not available early enough to set it as a browser pref
     var env = Cc["@mozilla.org/process/environment;1"].getService(
       Ci.nsIEnvironment
     );
 
     if (env.exists("TPPROFILINGINFO")) {
@@ -299,16 +301,23 @@ function plInit() {
           false,
           true
         );
         content.selectedBrowser.messageManager.loadFrameScript(
           "chrome://pageloader/content/Profiler.js",
           false,
           true
         );
+        if (useA11y) {
+          content.selectedBrowser.messageManager.loadFrameScript(
+            "chrome://pageloader/content/a11y.js",
+            false,
+            true
+          );
+        }
 
         // Ensure that any webextensions that need to do setup have a chance
         // to do so. e.g. the 'tabswitch' talos test registers a about:tabswitch
         // handler during initialization, and if we don't wait for that, then
         // attempting to load that URL will result in an error and hang the
         // test.
         setTimeout(plLoadPage, 2000);
       }, 500);
--- a/testing/talos/talos/run_tests.py
+++ b/testing/talos/talos/run_tests.py
@@ -52,17 +52,17 @@ def set_tp_preferences(test, browser_con
     if test['gecko_profile']:
         LOG.info("Gecko profiling is enabled so talos is reducing the number "
                  "of cycles, please disregard reported numbers")
         for cycle_var in ['tppagecycles', 'tpcycles', 'cycles']:
             if test[cycle_var] > 2:
                 test[cycle_var] = 2
 
     CLI_bool_options = ['tpchrome', 'tphero', 'tpmozafterpaint', 'tploadnocache', 'tpscrolltest',
-                        'fnbpaint', 'pdfpaint']
+                        'fnbpaint', 'pdfpaint', 'a11y']
     CLI_options = ['tpcycles', 'tppagecycles', 'tptimeout', 'tpmanifest']
     for key in CLI_bool_options:
         _pref_name = "talos.%s" % key
         if key in test:
             test['preferences'][_pref_name] = test.get(key)
         else:
             # current test doesn't use this setting, remove it from our prefs
             if _pref_name in test['preferences']:
--- a/testing/talos/talos/test.py
+++ b/testing/talos/talos/test.py
@@ -263,17 +263,17 @@ class PageloaderTest(Test):
             'userready', 'testeventmap', 'base_vs_ref', 'mainthread', 'resolution',
             'cycles', 'gecko_profile', 'gecko_profile_interval', 'gecko_profile_entries',
             'tptimeout', 'win_counters', 'w7_counters', 'linux_counters', 'mac_counters',
             'tpscrolltest', 'xperf_counters', 'timeout', 'responsiveness',
             'profile_path', 'xperf_providers', 'xperf_user_providers', 'xperf_stackwalk',
             'format_pagename', 'filters', 'preferences', 'extensions', 'setup', 'cleanup',
             'lower_is_better', 'alert_threshold', 'unit', 'webextensions', 'profile',
             'suite_should_alert', 'subtest_alerts', 'perfherder_framework', 'pdfpaint',
-            'webextensions_folder']
+            'webextensions_folder', 'a11y']
 
 
 class QuantumPageloadTest(PageloaderTest):
     """
     Base class for a Quantum Pageload test
     """
     tpcycles = 1
     tppagecycles = 25
@@ -835,16 +835,17 @@ class a11yr(PageloaderTest):
     tpmanifest = '${talos}/tests/a11y/a11y.manifest'
     tpcycles = 1
     tppagecycles = 25
     tpmozafterpaint = True
     tpchrome = False
     preferences = {'dom.send_after_paint_to_content': False}
     unit = 'ms'
     alert_threshold = 5.0
+    a11y = True
 
 
 class WebkitBenchmark(PageloaderTest):
     tpcycles = 1
     tppagecycles = 5
     tpmozafterpaint = False
     tpchrome = False
     format_pagename = False
--- a/testing/talos/talos/tests/a11y/dhtml.html
+++ b/testing/talos/talos/tests/a11y/dhtml.html
@@ -1,16 +1,16 @@
 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
 <html>
 <meta charset="utf-8">
 <head>
 <title>accessibility perf for dhtml</title>
-<script src="a11y.js"></script>
 <script src="resource://talos-powers/TalosContentProfiler.js"></script>
 <script>
+  /* globals initAccessibility */
   // based on: http://hacks.mozilla.org/2010/05/better-performance-with-lazy-frame-construction/
   var ppDate = null;
 
   function doInsertion() {
     if (!initAccessibility()) {
       dump("__FAILinit:AccessibilityUnvailable__FAIL");
       return;
     }
--- a/testing/talos/talos/tests/a11y/tablemutation.html
+++ b/testing/talos/talos/tests/a11y/tablemutation.html
@@ -1,12 +1,11 @@
 <head>
 <meta charset="utf-8">
 <title>Accessibility Table Mutation</title>
-<script src="a11y.js"></script>
 <script src="resource://talos-powers/TalosContentProfiler.js"></script>
 </head>
 
 <body>
 <div id="start">
 <table id="datatable">
 <tr><td>Row #0</td><td>348003</td><td>745393</td><td>658838</td><td>273744</td></tr><tr><td>Row #1</td><td>482498</td><td>724073</td><td>792474</td><td>549091</td></tr><tr><td>Row #2</td><td>639859</td><td>151692</td><td>251949</td><td>323840</td></tr><tr><td>Row #3</td><td>269274</td><td>211292</td><td>892989</td><td>473276</td></tr><tr><td>Row #4</td><td>148736</td><td>438719</td><td>789802</td><td>986023</td></tr><tr><td>Row #5</td><td>999863</td><td>782360</td><td>648663</td><td>959764</td></tr><tr><td>Row #6</td><td>302562</td><td>122962</td><td>623747</td><td>961374</td></tr><tr><td>Row #7</td><td>620408</td><td>740513</td><td>562968</td><td>868412</td></tr><tr><td>Row #8</td><td>485907</td><td>221807</td><td>142157</td><td>868405</td></tr><tr><td>Row #9</td><td>845880</td><td>834632</td><td>417497</td><td>485740</td></tr><tr><td>Row #10</td><td>886324</td><td>569447</td><td>709581</td><td>155598</td></tr><tr><td>Row #11</td><td>680740</td><td>602570</td><td>528874</td><td>729476</td></tr><tr><td>Row #12</td><td>941289</td><td>318677</td><td>715499</td><td>941153</td></tr><tr><td>Row #13</td><td>101037</td><td>364163</td><td>900918</td><td>303600</td></tr><tr><td>Row #14</td><td>387126</td><td>524665</td><td>264974</td><td>907534</td></tr><tr><td>Row #15</td><td>265179</td><td>727943</td><td>775947</td><td>651086</td></tr><tr><td>Row #16</td><td>849750</td><td>818104</td><td>519492</td><td>695631</td></tr><tr><td>Row #17</td><td>652736</td><td>836990</td><td>181371</td><td>539061</td></tr><tr><td>Row #18</td><td>406437</td><td>790952</td><td>594659</td><td>987177</td></tr><tr><td>Row #19</td><td>393523</td><td>123534</td><td>716653</td><td>334813</td></tr><tr><td>Row #20</td><td>342211</td><td>432153</td><td>275966</td><td>343248</td></tr><tr><td>Row #21</td><td>696316</td><td>176885</td><td>546849</td><td>983442</td></tr><tr><td>Row #22</td><td>601550</td><td>711824</td><td>890977</td><td>766730</td></tr><tr><td>Row #23</td><td>439767</td><td>666925</td><td>417816</td><td>289518</td></tr><tr><td>Row #24</td><td>485029</td><td>837309</td><td>885150</td><td>137766</td></tr>
 <tr><td>Row #0</td><td>348003</td><td>745393</td><td>658838</td><td>273744</td></tr><tr><td>Row #1</td><td>482498</td><td>724073</td><td>792474</td><td>549091</td></tr><tr><td>Row #2</td><td>639859</td><td>151692</td><td>251949</td><td>323840</td></tr><tr><td>Row #3</td><td>269274</td><td>211292</td><td>892989</td><td>473276</td></tr><tr><td>Row #4</td><td>148736</td><td>438719</td><td>789802</td><td>986023</td></tr><tr><td>Row #5</td><td>999863</td><td>782360</td><td>648663</td><td>959764</td></tr><tr><td>Row #6</td><td>302562</td><td>122962</td><td>623747</td><td>961374</td></tr><tr><td>Row #7</td><td>620408</td><td>740513</td><td>562968</td><td>868412</td></tr><tr><td>Row #8</td><td>485907</td><td>221807</td><td>142157</td><td>868405</td></tr><tr><td>Row #9</td><td>845880</td><td>834632</td><td>417497</td><td>485740</td></tr><tr><td>Row #10</td><td>886324</td><td>569447</td><td>709581</td><td>155598</td></tr><tr><td>Row #11</td><td>680740</td><td>602570</td><td>528874</td><td>729476</td></tr><tr><td>Row #12</td><td>941289</td><td>318677</td><td>715499</td><td>941153</td></tr><tr><td>Row #13</td><td>101037</td><td>364163</td><td>900918</td><td>303600</td></tr><tr><td>Row #14</td><td>387126</td><td>524665</td><td>264974</td><td>907534</td></tr><tr><td>Row #15</td><td>265179</td><td>727943</td><td>775947</td><td>651086</td></tr><tr><td>Row #16</td><td>849750</td><td>818104</td><td>519492</td><td>695631</td></tr><tr><td>Row #17</td><td>652736</td><td>836990</td><td>181371</td><td>539061</td></tr><tr><td>Row #18</td><td>406437</td><td>790952</td><td>594659</td><td>987177</td></tr><tr><td>Row #19</td><td>393523</td><td>123534</td><td>716653</td><td>334813</td></tr><tr><td>Row #20</td><td>342211</td><td>432153</td><td>275966</td><td>343248</td></tr><tr><td>Row #21</td><td>696316</td><td>176885</td><td>546849</td><td>983442</td></tr><tr><td>Row #22</td><td>601550</td><td>711824</td><td>890977</td><td>766730</td></tr><tr><td>Row #23</td><td>439767</td><td>666925</td><td>417816</td><td>289518</td></tr><tr><td>Row #24</td><td>485029</td><td>837309</td><td>885150</td><td>137766</td></tr>
@@ -72,16 +71,17 @@
 <tr><td>Row #0</td><td>348003</td><td>745393</td><td>658838</td><td>273744</td></tr><tr><td>Row #1</td><td>482498</td><td>724073</td><td>792474</td><td>549091</td></tr><tr><td>Row #2</td><td>639859</td><td>151692</td><td>251949</td><td>323840</td></tr><tr><td>Row #3</td><td>269274</td><td>211292</td><td>892989</td><td>473276</td></tr><tr><td>Row #4</td><td>148736</td><td>438719</td><td>789802</td><td>986023</td></tr><tr><td>Row #5</td><td>999863</td><td>782360</td><td>648663</td><td>959764</td></tr><tr><td>Row #6</td><td>302562</td><td>122962</td><td>623747</td><td>961374</td></tr><tr><td>Row #7</td><td>620408</td><td>740513</td><td>562968</td><td>868412</td></tr><tr><td>Row #8</td><td>485907</td><td>221807</td><td>142157</td><td>868405</td></tr><tr><td>Row #9</td><td>845880</td><td>834632</td><td>417497</td><td>485740</td></tr><tr><td>Row #10</td><td>886324</td><td>569447</td><td>709581</td><td>155598</td></tr><tr><td>Row #11</td><td>680740</td><td>602570</td><td>528874</td><td>729476</td></tr><tr><td>Row #12</td><td>941289</td><td>318677</td><td>715499</td><td>941153</td></tr><tr><td>Row #13</td><td>101037</td><td>364163</td><td>900918</td><td>303600</td></tr><tr><td>Row #14</td><td>387126</td><td>524665</td><td>264974</td><td>907534</td></tr><tr><td>Row #15</td><td>265179</td><td>727943</td><td>775947</td><td>651086</td></tr><tr><td>Row #16</td><td>849750</td><td>818104</td><td>519492</td><td>695631</td></tr><tr><td>Row #17</td><td>652736</td><td>836990</td><td>181371</td><td>539061</td></tr><tr><td>Row #18</td><td>406437</td><td>790952</td><td>594659</td><td>987177</td></tr><tr><td>Row #19</td><td>393523</td><td>123534</td><td>716653</td><td>334813</td></tr><tr><td>Row #20</td><td>342211</td><td>432153</td><td>275966</td><td>343248</td></tr><tr><td>Row #21</td><td>696316</td><td>176885</td><td>546849</td><td>983442</td></tr><tr><td>Row #22</td><td>601550</td><td>711824</td><td>890977</td><td>766730</td></tr><tr><td>Row #23</td><td>439767</td><td>666925</td><td>417816</td><td>289518</td></tr><tr><td>Row #24</td><td>485029</td><td>837309</td><td>885150</td><td>137766</td></tr>
 <tr><td>Row #0</td><td>348003</td><td>745393</td><td>658838</td><td>273744</td></tr><tr><td>Row #1</td><td>482498</td><td>724073</td><td>792474</td><td>549091</td></tr><tr><td>Row #2</td><td>639859</td><td>151692</td><td>251949</td><td>323840</td></tr><tr><td>Row #3</td><td>269274</td><td>211292</td><td>892989</td><td>473276</td></tr><tr><td>Row #4</td><td>148736</td><td>438719</td><td>789802</td><td>986023</td></tr><tr><td>Row #5</td><td>999863</td><td>782360</td><td>648663</td><td>959764</td></tr><tr><td>Row #6</td><td>302562</td><td>122962</td><td>623747</td><td>961374</td></tr><tr><td>Row #7</td><td>620408</td><td>740513</td><td>562968</td><td>868412</td></tr><tr><td>Row #8</td><td>485907</td><td>221807</td><td>142157</td><td>868405</td></tr><tr><td>Row #9</td><td>845880</td><td>834632</td><td>417497</td><td>485740</td></tr><tr><td>Row #10</td><td>886324</td><td>569447</td><td>709581</td><td>155598</td></tr><tr><td>Row #11</td><td>680740</td><td>602570</td><td>528874</td><td>729476</td></tr><tr><td>Row #12</td><td>941289</td><td>318677</td><td>715499</td><td>941153</td></tr><tr><td>Row #13</td><td>101037</td><td>364163</td><td>900918</td><td>303600</td></tr><tr><td>Row #14</td><td>387126</td><td>524665</td><td>264974</td><td>907534</td></tr><tr><td>Row #15</td><td>265179</td><td>727943</td><td>775947</td><td>651086</td></tr><tr><td>Row #16</td><td>849750</td><td>818104</td><td>519492</td><td>695631</td></tr><tr><td>Row #17</td><td>652736</td><td>836990</td><td>181371</td><td>539061</td></tr><tr><td>Row #18</td><td>406437</td><td>790952</td><td>594659</td><td>987177</td></tr><tr><td>Row #19</td><td>393523</td><td>123534</td><td>716653</td><td>334813</td></tr><tr><td>Row #20</td><td>342211</td><td>432153</td><td>275966</td><td>343248</td></tr><tr><td>Row #21</td><td>696316</td><td>176885</td><td>546849</td><td>983442</td></tr><tr><td>Row #22</td><td>601550</td><td>711824</td><td>890977</td><td>766730</td></tr><tr><td>Row #23</td><td>439767</td><td>666925</td><td>417816</td><td>289518</td></tr><tr><td>Row #24</td><td>485029</td><td>837309</td><td>885150</td><td>137766</td></tr>
 <tr><td>Row #0</td><td>348003</td><td>745393</td><td>658838</td><td>273744</td></tr><tr><td>Row #1</td><td>482498</td><td>724073</td><td>792474</td><td>549091</td></tr><tr><td>Row #2</td><td>639859</td><td>151692</td><td>251949</td><td>323840</td></tr><tr><td>Row #3</td><td>269274</td><td>211292</td><td>892989</td><td>473276</td></tr><tr><td>Row #4</td><td>148736</td><td>438719</td><td>789802</td><td>986023</td></tr><tr><td>Row #5</td><td>999863</td><td>782360</td><td>648663</td><td>959764</td></tr><tr><td>Row #6</td><td>302562</td><td>122962</td><td>623747</td><td>961374</td></tr><tr><td>Row #7</td><td>620408</td><td>740513</td><td>562968</td><td>868412</td></tr><tr><td>Row #8</td><td>485907</td><td>221807</td><td>142157</td><td>868405</td></tr><tr><td>Row #9</td><td>845880</td><td>834632</td><td>417497</td><td>485740</td></tr><tr><td>Row #10</td><td>886324</td><td>569447</td><td>709581</td><td>155598</td></tr><tr><td>Row #11</td><td>680740</td><td>602570</td><td>528874</td><td>729476</td></tr><tr><td>Row #12</td><td>941289</td><td>318677</td><td>715499</td><td>941153</td></tr><tr><td>Row #13</td><td>101037</td><td>364163</td><td>900918</td><td>303600</td></tr><tr><td>Row #14</td><td>387126</td><td>524665</td><td>264974</td><td>907534</td></tr><tr><td>Row #15</td><td>265179</td><td>727943</td><td>775947</td><td>651086</td></tr><tr><td>Row #16</td><td>849750</td><td>818104</td><td>519492</td><td>695631</td></tr><tr><td>Row #17</td><td>652736</td><td>836990</td><td>181371</td><td>539061</td></tr><tr><td>Row #18</td><td>406437</td><td>790952</td><td>594659</td><td>987177</td></tr><tr><td>Row #19</td><td>393523</td><td>123534</td><td>716653</td><td>334813</td></tr><tr><td>Row #20</td><td>342211</td><td>432153</td><td>275966</td><td>343248</td></tr><tr><td>Row #21</td><td>696316</td><td>176885</td><td>546849</td><td>983442</td></tr><tr><td>Row #22</td><td>601550</td><td>711824</td><td>890977</td><td>766730</td></tr><tr><td>Row #23</td><td>439767</td><td>666925</td><td>417816</td><td>289518</td></tr><tr><td>Row #24</td><td>485029</td><td>837309</td><td>885150</td><td>137766</td></tr>
 </table>
 </div>
 
 </body>
 <script>
+/* globals initAccessibility, ensureAccessibleTreeForId */
 window.onload = function() {
   setTimeout(function() {
     mutateTable();
   }, 100);
 };
 function mutateTable() {
   var htmTable = document.getElementById("datatable");
   var TableRows = [ ];