Просмотр исходного кода

suppress noise from early initialization during unit tests

the tests still all passed, but the missing browser globals in the node environment could cause misleading messages in the mocha output
El RIDO 9 месяцев назад
Родитель
Сommit
ead315251f
1 измененных файлов с 5 добавлено и 0 удалено
  1. 5 0
      js/legacy.js

+ 5 - 0
js/legacy.js

@@ -246,6 +246,11 @@
          */
          */
         me.init = function()
         me.init = function()
         {
         {
+            // prevent early init
+            if (typeof document === 'undefined' || typeof navigator === 'undefined' || typeof window === 'undefined') {
+                return;
+            }
+
             // prevent bots from viewing a document and potentially deleting data
             // prevent bots from viewing a document and potentially deleting data
             // when burn-after-reading is set
             // when burn-after-reading is set
             if (isBadBot()) {
             if (isBadBot()) {