From 32d0467881abde195c9da1be91ee809c869ab35f Mon Sep 17 00:00:00 2001 From: Joffrey JAFFEUX Date: Tue, 27 Jul 2021 14:42:21 +0200 Subject: [PATCH] DEV: avoids using document.write (#13858) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It doesn’t provide much than just avoiding some logs in tests. I didn't change test_starter as it's going to be removed at some point. --- .../javascripts/discourse/tests/test-helper.js | 18 ++++++++++-------- .../javascripts/wizard/test/test_helper.js | 17 +++++++++-------- 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/app/assets/javascripts/discourse/tests/test-helper.js b/app/assets/javascripts/discourse/tests/test-helper.js index 299a37c7807..f66fa1fe0d9 100644 --- a/app/assets/javascripts/discourse/tests/test-helper.js +++ b/app/assets/javascripts/discourse/tests/test-helper.js @@ -8,14 +8,16 @@ document.addEventListener("discourse-booted", () => { let setupTests = require("discourse/tests/setup-tests").default; Ember.ENV.LOG_STACKTRACE_ON_DEPRECATION = false; - document.write(` -
-
- -
-
-
- `); + document.body.insertAdjacentHTML( + "afterbegin", + ` +
+
+
+
+
+ ` + ); setupTests(config.APP); start({ setupTestContainer: false }); diff --git a/app/assets/javascripts/wizard/test/test_helper.js b/app/assets/javascripts/wizard/test/test_helper.js index 9e9d3f99a83..f3ffbfce88f 100644 --- a/app/assets/javascripts/wizard/test/test_helper.js +++ b/app/assets/javascripts/wizard/test/test_helper.js @@ -24,14 +24,15 @@ //= require ./wizard-pretender //= require test-shims -// Trick JSHint into allow document.write -let d = document; -d.write( - '
' -); -d.write( - "" -); +document.addEventListener("DOMContentLoaded", function () { + document.body.insertAdjacentHTML( + "afterbegin", + ` +
+ + ` + ); +}); if (window.Logster) { Logster.enabled = false;