Bug 1538306 - ensure that only one audit can run at a given time for an Accessible actor. r=pbro
authorYura Zenevich <yura.zenevich@gmail.com>
Tue, 26 Mar 2019 13:33:29 +0000
changeset 466096 72b740c734db3f2241236f35168c5da0658ffa1c
parent 466095 73a48619739e34609d11f5ed15f3fc1436ee154f
child 466097 76e7655d974e628646aa26b7d25fe7ef3a4ec615
push id81440
push useryura.zenevich@gmail.com
push dateTue, 26 Mar 2019 13:35:22 +0000
treeherderautoland@76e7655d974e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspbro
bugs1538306
milestone68.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 1538306 - ensure that only one audit can run at a given time for an Accessible actor. r=pbro Differential Revision: https://phabricator.services.mozilla.com/D24545
devtools/server/actors/accessibility/accessible.js
--- a/devtools/server/actors/accessibility/accessible.js
+++ b/devtools/server/actors/accessibility/accessible.js
@@ -402,26 +402,37 @@ const AccessibleActor = ActorClassWithSp
 
   /**
    * Audit the state of the accessible object.
    *
    * @return {Object|null}
    *         Audit results for the accessible object.
   */
   async audit() {
-    // More audit steps will be added here in the near future. In addition to colour
-    // contrast ratio we will add autits for to the missing names, invalid states, etc.
-    // (For example see bug 1518808).
-    const [ contrastRatio ] = await Promise.all([
+    if (this._auditing) {
+      return this._auditing;
+    }
+
+    // More audit steps will be added here in the near future. In addition to
+    // colour contrast ratio we will add autits for to the missing names,
+    // invalid states, etc. (For example see bug 1518808).
+    this._auditing = Promise.all([
       this._getContrastRatio(),
-    ]);
+    ]).then(([
+      contrastRatio,
+    ]) => {
+      const audit = this.isDefunct ? null : {
+        contrastRatio,
+      };
 
-    return this.isDefunct ? null : {
-      contrastRatio,
-    };
+      this._auditing = null;
+      return audit;
+    });
+
+    return this._auditing;
   },
 
   snapshot() {
     return getSnapshot(this.rawAccessible, this.walker.a11yService);
   },
 });
 
 exports.AccessibleActor = AccessibleActor;