From 73aa06275a8c7eba19cbcfab323ad2062b273c00 Mon Sep 17 00:00:00 2001
From: Mike Pennisi <mike@mikepennisi.com>
Date: Thu, 18 Jun 2015 13:40:05 -0400
Subject: [PATCH] Update browser runner to inject `assert.js`

Since the Python runner was updated to include `assert.js` in all tests
unconditionally, a number of tests have been written that implicitly
rely on its presence. The browser runner does not currently provide this
file's contents to these tests, so they fail unconditionally.

Update the browser runner to inject that file's contents into every test
context.

Note: the existing approach to file retrieval (namely loading via
synchronous XHR requests) is inefficient and deprecated in some
browsers. It is honored here for the sake of consistency and to minimize
the changeset necessary to fix the browser runner.
---
 harness/sth.js                                     | 10 ++++++++++
 tools/packaging/templates/runner.bestPractice.html |  1 -
 tools/packaging/templates/runner.intl402.html      |  1 -
 tools/packaging/templates/runner.test262.html      |  1 -
 4 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/harness/sth.js b/harness/sth.js
index c3f94c6b8a..3a6e9ca9dc 100644
--- a/harness/sth.js
+++ b/harness/sth.js
@@ -27,6 +27,7 @@ function BrowserRunner() {
         errorDetectorFileContents,
         simpleTestAPIContents,
         globalScopeContents,
+        assertContents,
         timerContents,
         startTime,
         harnessDir = "harness/";
@@ -45,6 +46,11 @@ function BrowserRunner() {
             dataType: "text",
             success: function(data){globalScopeContents = data;},
             url:harnessDir+"gs.js"});
+
+    $.ajax({async: false,
+            dataType: "text",
+            success: function(data){assertContents = data;},
+            url:harnessDir+"assert.js"});
     
 	$.ajax({async: false,
 		dataType: "text",
@@ -215,6 +221,10 @@ function BrowserRunner() {
         idoc.writeln(globalScopeContents);
         idoc.writeln("</script>");
 
+        idoc.writeln("<script type='text/javascript'>");
+        idoc.writeln(assertContents);
+        idoc.writeln("</script>");
+
         //this is mainly applicable for consoles that do not have setTimeout support
 		//idoc.writeln("<script type='text/javascript' src='harness/timer.js' defer>" + "</script>");
         if(setTimeout === undefined && isAsyncTest(code)) {
diff --git a/tools/packaging/templates/runner.bestPractice.html b/tools/packaging/templates/runner.bestPractice.html
index 5f2d4df723..60c3bbef6f 100644
--- a/tools/packaging/templates/runner.bestPractice.html
+++ b/tools/packaging/templates/runner.bestPractice.html
@@ -11,7 +11,6 @@
 </script>
 <script type="text/javascript" src="harness/sth.js"></script>
 <script type="text/javascript" src="harness/sta.js"></script>
-<script type="text/javascript" src="harness/assert.js"></script>
 <script type="text/javascript" src="harness/jqueryprogressbar.js"></script>
 <script type="text/javascript" src="harness/helper.js"></script>
 <script type="text/javascript" src="harness/jquery.base64.js"></script>
diff --git a/tools/packaging/templates/runner.intl402.html b/tools/packaging/templates/runner.intl402.html
index 989d734bf6..11f8321f06 100644
--- a/tools/packaging/templates/runner.intl402.html
+++ b/tools/packaging/templates/runner.intl402.html
@@ -11,7 +11,6 @@
 </script>
 <script type="text/javascript" src="harness/sth.js"></script>
 <script type="text/javascript" src="harness/sta.js"></script>
-<script type="text/javascript" src="harness/assert.js"></script>
 <script type="text/javascript" src="harness/jqueryprogressbar.js"></script>
 <script type="text/javascript" src="harness/helper.js"></script>
 <script type="text/javascript" src="harness/jquery.base64.js"></script>
diff --git a/tools/packaging/templates/runner.test262.html b/tools/packaging/templates/runner.test262.html
index 60745b96e4..9f51b6b02b 100644
--- a/tools/packaging/templates/runner.test262.html
+++ b/tools/packaging/templates/runner.test262.html
@@ -11,7 +11,6 @@
 </script>
 <script type="text/javascript" src="harness/sth.js"></script>
 <script type="text/javascript" src="harness/sta.js"></script>
-<script type="text/javascript" src="harness/assert.js"></script>
 <script type="text/javascript" src="harness/jqueryprogressbar.js"></script>
 <script type="text/javascript" src="harness/helper.js"></script>
 <script type="text/javascript" src="harness/jquery.base64.js"></script>
-- 
GitLab