<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[212147] trunk/LayoutTests</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/212147">212147</a></dd>
<dt>Author</dt> <dd>cdumez@apple.com</dd>
<dt>Date</dt> <dd>2017-02-10 13:51:44 -0800 (Fri, 10 Feb 2017)</dd>
</dl>

<h3>Log Message</h3>
<pre>Update LayoutTests/resources/testharness.js
https://bugs.webkit.org/show_bug.cgi?id=168100

Reviewed by Youenn Fablet.

Update LayoutTests/resources/testharness.js to match the web-platform-tests
one landed in <a href="http://trac.webkit.org/projects/webkit/changeset/211930">r211930</a>.

* media/track/w3c/interfaces/HTMLTrackElement/srclang-expected.txt:
* media/track/w3c/interfaces/TextTrack/language-expected.txt:
* resources/testharness.js:
(SharedWorkerTestEnvironment):
(ServiceWorkerTestEnvironment):
(create_test_environment):
(promise_test):
(EventWatcher):
(is_node):
(format_value):
* streams/shadowing-Promise-expected.txt:
* streams/shadowing-Promise.html:
* streams/streams-public-array-api-expected.txt: Added.
* streams/streams-public-array-api.html: Added.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsmediatrackw3cinterfacesHTMLTrackElementsrclangexpectedtxt">trunk/LayoutTests/media/track/w3c/interfaces/HTMLTrackElement/srclang-expected.txt</a></li>
<li><a href="#trunkLayoutTestsmediatrackw3cinterfacesTextTracklanguageexpectedtxt">trunk/LayoutTests/media/track/w3c/interfaces/TextTrack/language-expected.txt</a></li>
<li><a href="#trunkLayoutTestsresourcestestharnessjs">trunk/LayoutTests/resources/testharness.js</a></li>
<li><a href="#trunkLayoutTestsstreamsshadowingPromiseexpectedtxt">trunk/LayoutTests/streams/shadowing-Promise-expected.txt</a></li>
<li><a href="#trunkLayoutTestsstreamsshadowingPromisehtml">trunk/LayoutTests/streams/shadowing-Promise.html</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsstreamsstreamspublicarrayapiexpectedtxt">trunk/LayoutTests/streams/streams-public-array-api-expected.txt</a></li>
<li><a href="#trunkLayoutTestsstreamsstreamspublicarrayapihtml">trunk/LayoutTests/streams/streams-public-array-api.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (212146 => 212147)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2017-02-10 21:34:27 UTC (rev 212146)
+++ trunk/LayoutTests/ChangeLog        2017-02-10 21:51:44 UTC (rev 212147)
</span><span class="lines">@@ -1,3 +1,28 @@
</span><ins>+2017-02-10  Chris Dumez  &lt;cdumez@apple.com&gt;
+
+        Update LayoutTests/resources/testharness.js
+        https://bugs.webkit.org/show_bug.cgi?id=168100
+
+        Reviewed by Youenn Fablet.
+
+        Update LayoutTests/resources/testharness.js to match the web-platform-tests
+        one landed in r211930.
+
+        * media/track/w3c/interfaces/HTMLTrackElement/srclang-expected.txt:
+        * media/track/w3c/interfaces/TextTrack/language-expected.txt:
+        * resources/testharness.js:
+        (SharedWorkerTestEnvironment):
+        (ServiceWorkerTestEnvironment):
+        (create_test_environment):
+        (promise_test):
+        (EventWatcher):
+        (is_node):
+        (format_value):
+        * streams/shadowing-Promise-expected.txt:
+        * streams/shadowing-Promise.html:
+        * streams/streams-public-array-api-expected.txt: Added.
+        * streams/streams-public-array-api.html: Added.
+
</ins><span class="cx"> 2017-02-10  Ryan Haddad  &lt;ryanhaddad@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Skip some very slow WebCryptoAPI tests.
</span></span></pre></div>
<a id="trunkLayoutTestsmediatrackw3cinterfacesHTMLTrackElementsrclangexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/media/track/w3c/interfaces/HTMLTrackElement/srclang-expected.txt (212146 => 212147)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/media/track/w3c/interfaces/HTMLTrackElement/srclang-expected.txt        2017-02-10 21:34:27 UTC (rev 212146)
+++ trunk/LayoutTests/media/track/w3c/interfaces/HTMLTrackElement/srclang-expected.txt        2017-02-10 21:51:44 UTC (rev 212147)
</span><span class="lines">@@ -1,9 +1,9 @@
</span><span class="cx"> CONSOLE MESSAGE: line 43: The language contains a null character and is not a valid BCP 47 language tag.
</span><span class="cx"> CONSOLE MESSAGE: line 64: The language ' foo 
</span><span class="cx"> ' is not a valid BCP 47 language tag.
</span><del>-CONSOLE MESSAGE: line 1380: The language ' foo 
</del><ins>+CONSOLE MESSAGE: line 1409: The language ' foo 
</ins><span class="cx"> ' is not a valid BCP 47 language tag.
</span><del>-CONSOLE MESSAGE: line 1380: The language contains a null character and is not a valid BCP 47 language tag.
</del><ins>+CONSOLE MESSAGE: line 1409: The language contains a null character and is not a valid BCP 47 language tag.
</ins><span class="cx"> 
</span><span class="cx"> PASS HTMLTrackElement.srclang missing value 
</span><span class="cx"> PASS HTMLTrackElement.srclang empty string content attribute 
</span></span></pre></div>
<a id="trunkLayoutTestsmediatrackw3cinterfacesTextTracklanguageexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/media/track/w3c/interfaces/TextTrack/language-expected.txt (212146 => 212147)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/media/track/w3c/interfaces/TextTrack/language-expected.txt        2017-02-10 21:34:27 UTC (rev 212146)
+++ trunk/LayoutTests/media/track/w3c/interfaces/TextTrack/language-expected.txt        2017-02-10 21:51:44 UTC (rev 212147)
</span><span class="lines">@@ -1,4 +1,4 @@
</span><del>-CONSOLE MESSAGE: line 1380: The language contains a null character and is not a valid BCP 47 language tag.
</del><ins>+CONSOLE MESSAGE: line 1409: The language contains a null character and is not a valid BCP 47 language tag.
</ins><span class="cx"> CONSOLE MESSAGE: line 26: The language contains a null character and is not a valid BCP 47 language tag.
</span><span class="cx"> 
</span><span class="cx"> PASS TextTrack.language 
</span></span></pre></div>
<a id="trunkLayoutTestsresourcestestharnessjs"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/resources/testharness.js (212146 => 212147)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/resources/testharness.js        2017-02-10 21:34:27 UTC (rev 212146)
+++ trunk/LayoutTests/resources/testharness.js        2017-02-10 21:51:44 UTC (rev 212147)
</span><span class="lines">@@ -389,7 +389,7 @@
</span><span class="cx">         self.addEventListener(&quot;connect&quot;,
</span><span class="cx">                 function(message_event) {
</span><span class="cx">                     this_obj._add_message_port(message_event.source);
</span><del>-                });
</del><ins>+                }, false);
</ins><span class="cx">     }
</span><span class="cx">     SharedWorkerTestEnvironment.prototype = Object.create(WorkerTestEnvironment.prototype);
</span><span class="cx"> 
</span><span class="lines">@@ -430,7 +430,7 @@
</span><span class="cx">                             this_obj._add_message_port(event.source);
</span><span class="cx">                         }
</span><span class="cx">                     }
</span><del>-                });
</del><ins>+                }, false);
</ins><span class="cx"> 
</span><span class="cx">         // The oninstall event is received after the service worker script and
</span><span class="cx">         // all imported scripts have been fetched and executed. It's the
</span><span class="lines">@@ -471,6 +471,11 @@
</span><span class="cx">             self instanceof ServiceWorkerGlobalScope) {
</span><span class="cx">             return new ServiceWorkerTestEnvironment();
</span><span class="cx">         }
</span><ins>+        if ('WorkerGlobalScope' in self &amp;&amp;
+            self instanceof WorkerGlobalScope) {
+            return new DedicatedWorkerTestEnvironment();
+        }
+
</ins><span class="cx">         throw new Error(&quot;Unsupported test environment&quot;);
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -518,14 +523,18 @@
</span><span class="cx">     function promise_test(func, name, properties) {
</span><span class="cx">         var test = async_test(name, properties);
</span><span class="cx">         // If there is no promise tests queue make one.
</span><del>-        test.step(function() {
-            if (!tests.promise_tests) {
-                tests.promise_tests = Promise.resolve();
-            }
-        });
</del><ins>+        if (!tests.promise_tests) {
+            tests.promise_tests = Promise.resolve();
+        }
</ins><span class="cx">         tests.promise_tests = tests.promise_tests.then(function() {
</span><del>-            return Promise.resolve(test.step(func, test, test))
-                .then(
</del><ins>+            var donePromise = new Promise(function(resolve) {
+                test.add_cleanup(resolve);
+            });
+            var promise = test.step(func, test, test);
+            test.step(function() {
+                assert_not_equals(promise, undefined);
+            });
+            Promise.resolve(promise).then(
</ins><span class="cx">                     function() {
</span><span class="cx">                         test.done();
</span><span class="cx">                     })
</span><span class="lines">@@ -537,12 +546,13 @@
</span><span class="cx">                         assert(false, &quot;promise_test&quot;, null,
</span><span class="cx">                                &quot;Unhandled rejection with value: ${value}&quot;, {value:value});
</span><span class="cx">                     }));
</span><ins>+            return donePromise;
</ins><span class="cx">         });
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    function promise_rejects(test, expected, promise) {
-        return promise.then(test.unreached_func(&quot;Should have rejected.&quot;)).catch(function(e) {
-            assert_throws(expected, function() { throw e });
</del><ins>+    function promise_rejects(test, expected, promise, description) {
+        return promise.then(test.unreached_func(&quot;Should have rejected: &quot; + description)).catch(function(e) {
+            assert_throws(expected, function() { throw e }, description);
</ins><span class="cx">         });
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -579,7 +589,7 @@
</span><span class="cx">         });
</span><span class="cx"> 
</span><span class="cx">         for (var i = 0; i &lt; eventTypes.length; i++) {
</span><del>-            watchedNode.addEventListener(eventTypes[i], eventHandler);
</del><ins>+            watchedNode.addEventListener(eventTypes[i], eventHandler, false);
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         /**
</span><span class="lines">@@ -604,7 +614,7 @@
</span><span class="cx"> 
</span><span class="cx">         function stop_watching() {
</span><span class="cx">             for (var i = 0; i &lt; eventTypes.length; i++) {
</span><del>-                watchedNode.removeEventListener(eventTypes[i], eventHandler);
</del><ins>+                watchedNode.removeEventListener(eventTypes[i], eventHandler, false);
</ins><span class="cx">             }
</span><span class="cx">         };
</span><span class="cx"> 
</span><span class="lines">@@ -697,10 +707,17 @@
</span><span class="cx">         // instanceof doesn't work if the node is from another window (like an
</span><span class="cx">         // iframe's contentWindow):
</span><span class="cx">         // http://www.w3.org/Bugs/Public/show_bug.cgi?id=12295
</span><del>-        if (&quot;nodeType&quot; in object &amp;&amp;
-            &quot;nodeName&quot; in object &amp;&amp;
-            &quot;nodeValue&quot; in object &amp;&amp;
-            &quot;childNodes&quot; in object) {
</del><ins>+        try {
+            var has_node_properties = (&quot;nodeType&quot; in object &amp;&amp;
+                                       &quot;nodeName&quot; in object &amp;&amp;
+                                       &quot;nodeValue&quot; in object &amp;&amp;
+                                       &quot;childNodes&quot; in object);
+        } catch (e) {
+            // We're probably cross-origin, which means we aren't a node
+            return false;
+        }
+
+        if (has_node_properties) {
</ins><span class="cx">             try {
</span><span class="cx">                 object.nodeType;
</span><span class="cx">             } catch (e) {
</span><span class="lines">@@ -713,6 +730,44 @@
</span><span class="cx">         return false;
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    var replacements = {
+        &quot;0&quot;: &quot;0&quot;,
+        &quot;1&quot;: &quot;x01&quot;,
+        &quot;2&quot;: &quot;x02&quot;,
+        &quot;3&quot;: &quot;x03&quot;,
+        &quot;4&quot;: &quot;x04&quot;,
+        &quot;5&quot;: &quot;x05&quot;,
+        &quot;6&quot;: &quot;x06&quot;,
+        &quot;7&quot;: &quot;x07&quot;,
+        &quot;8&quot;: &quot;b&quot;,
+        &quot;9&quot;: &quot;t&quot;,
+        &quot;10&quot;: &quot;n&quot;,
+        &quot;11&quot;: &quot;v&quot;,
+        &quot;12&quot;: &quot;f&quot;,
+        &quot;13&quot;: &quot;r&quot;,
+        &quot;14&quot;: &quot;x0e&quot;,
+        &quot;15&quot;: &quot;x0f&quot;,
+        &quot;16&quot;: &quot;x10&quot;,
+        &quot;17&quot;: &quot;x11&quot;,
+        &quot;18&quot;: &quot;x12&quot;,
+        &quot;19&quot;: &quot;x13&quot;,
+        &quot;20&quot;: &quot;x14&quot;,
+        &quot;21&quot;: &quot;x15&quot;,
+        &quot;22&quot;: &quot;x16&quot;,
+        &quot;23&quot;: &quot;x17&quot;,
+        &quot;24&quot;: &quot;x18&quot;,
+        &quot;25&quot;: &quot;x19&quot;,
+        &quot;26&quot;: &quot;x1a&quot;,
+        &quot;27&quot;: &quot;x1b&quot;,
+        &quot;28&quot;: &quot;x1c&quot;,
+        &quot;29&quot;: &quot;x1d&quot;,
+        &quot;30&quot;: &quot;x1e&quot;,
+        &quot;31&quot;: &quot;x1f&quot;,
+        &quot;0xfffd&quot;: &quot;ufffd&quot;,
+        &quot;0xfffe&quot;: &quot;ufffe&quot;,
+        &quot;0xffff&quot;: &quot;uffff&quot;,
+    };
+
</ins><span class="cx">     /*
</span><span class="cx">      * Convert a value to a nice, human-readable string
</span><span class="cx">      */
</span><span class="lines">@@ -734,43 +789,9 @@
</span><span class="cx">         switch (typeof val) {
</span><span class="cx">         case &quot;string&quot;:
</span><span class="cx">             val = val.replace(&quot;\\&quot;, &quot;\\\\&quot;);
</span><del>-            for (var i = 0; i &lt; 32; i++) {
-                var replace = &quot;\\&quot;;
-                switch (i) {
-                case 0: replace += &quot;0&quot;; break;
-                case 1: replace += &quot;x01&quot;; break;
-                case 2: replace += &quot;x02&quot;; break;
-                case 3: replace += &quot;x03&quot;; break;
-                case 4: replace += &quot;x04&quot;; break;
-                case 5: replace += &quot;x05&quot;; break;
-                case 6: replace += &quot;x06&quot;; break;
-                case 7: replace += &quot;x07&quot;; break;
-                case 8: replace += &quot;b&quot;; break;
-                case 9: replace += &quot;t&quot;; break;
-                case 10: replace += &quot;n&quot;; break;
-                case 11: replace += &quot;v&quot;; break;
-                case 12: replace += &quot;f&quot;; break;
-                case 13: replace += &quot;r&quot;; break;
-                case 14: replace += &quot;x0e&quot;; break;
-                case 15: replace += &quot;x0f&quot;; break;
-                case 16: replace += &quot;x10&quot;; break;
-                case 17: replace += &quot;x11&quot;; break;
-                case 18: replace += &quot;x12&quot;; break;
-                case 19: replace += &quot;x13&quot;; break;
-                case 20: replace += &quot;x14&quot;; break;
-                case 21: replace += &quot;x15&quot;; break;
-                case 22: replace += &quot;x16&quot;; break;
-                case 23: replace += &quot;x17&quot;; break;
-                case 24: replace += &quot;x18&quot;; break;
-                case 25: replace += &quot;x19&quot;; break;
-                case 26: replace += &quot;x1a&quot;; break;
-                case 27: replace += &quot;x1b&quot;; break;
-                case 28: replace += &quot;x1c&quot;; break;
-                case 29: replace += &quot;x1d&quot;; break;
-                case 30: replace += &quot;x1e&quot;; break;
-                case 31: replace += &quot;x1f&quot;; break;
-                }
-                val = val.replace(RegExp(String.fromCharCode(i), &quot;g&quot;), replace);
</del><ins>+            for (var p in replacements) {
+                var replace = &quot;\\&quot; + replacements[p];
+                val = val.replace(RegExp(String.fromCharCode(p), &quot;g&quot;), replace);
</ins><span class="cx">             }
</span><span class="cx">             return '&quot;' + val.replace(/&quot;/g, '\\&quot;') + '&quot;';
</span><span class="cx">         case &quot;boolean&quot;:
</span><span class="lines">@@ -818,7 +839,12 @@
</span><span class="cx"> 
</span><span class="cx">         /* falls through */
</span><span class="cx">         default:
</span><del>-            return typeof val + ' &quot;' + truncate(String(val), 60) + '&quot;';
</del><ins>+            try {
+                return typeof val + ' &quot;' + truncate(String(val), 1000) + '&quot;';
+            } catch(e) {
+                return (&quot;[stringifying object threw &quot; + String(e) +
+                        &quot; with type &quot; + String(typeof e) + &quot;]&quot;);
+            }
</ins><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx">     expose(format_value, &quot;format_value&quot;);
</span><span class="lines">@@ -1176,6 +1202,7 @@
</span><span class="cx">                 NO_MODIFICATION_ALLOWED_ERR: 'NoModificationAllowedError',
</span><span class="cx">                 NOT_FOUND_ERR: 'NotFoundError',
</span><span class="cx">                 NOT_SUPPORTED_ERR: 'NotSupportedError',
</span><ins>+                INUSE_ATTRIBUTE_ERR: 'InUseAttributeError',
</ins><span class="cx">                 INVALID_STATE_ERR: 'InvalidStateError',
</span><span class="cx">                 SYNTAX_ERR: 'SyntaxError',
</span><span class="cx">                 INVALID_MODIFICATION_ERR: 'InvalidModificationError',
</span><span class="lines">@@ -1202,6 +1229,7 @@
</span><span class="cx">                 NoModificationAllowedError: 7,
</span><span class="cx">                 NotFoundError: 8,
</span><span class="cx">                 NotSupportedError: 9,
</span><ins>+                InUseAttributeError: 10,
</ins><span class="cx">                 InvalidStateError: 11,
</span><span class="cx">                 SyntaxError: 12,
</span><span class="cx">                 InvalidModificationError: 13,
</span><span class="lines">@@ -1226,6 +1254,7 @@
</span><span class="cx">                 ReadOnlyError: 0,
</span><span class="cx">                 VersionError: 0,
</span><span class="cx">                 OperationError: 0,
</span><ins>+                NotAllowedError: 0
</ins><span class="cx">             };
</span><span class="cx"> 
</span><span class="cx">             if (!(name in name_code_map)) {
</span><span class="lines">@@ -1436,7 +1465,7 @@
</span><span class="cx">         var args = Array.prototype.slice.call(arguments, 2);
</span><span class="cx">         return setTimeout(this.step_func(function() {
</span><span class="cx">             return f.apply(test_this, args);
</span><del>-        }, timeout * tests.timeout_multiplier));
</del><ins>+        }), timeout * tests.timeout_multiplier);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     Test.prototype.add_cleanup = function(callback) {
</span><span class="lines">@@ -2442,11 +2471,20 @@
</span><span class="cx">             }
</span><span class="cx">         }
</span><span class="cx"> 
</span><ins>+        // 'Error.stack' is not supported in all browsers/versions
+        if (!stack) {
+            return &quot;(Stack trace unavailable)&quot;;
+        }
+
</ins><span class="cx">         var lines = stack.split(&quot;\n&quot;);
</span><span class="cx"> 
</span><span class="cx">         // Create a pattern to match stack frames originating within testharness.js.  These include the
</span><span class="cx">         // script URL, followed by the line/col (e.g., '/resources/testharness.js:120:21').
</span><del>-        var re = new RegExp((get_script_url() || &quot;\\btestharness.js&quot;) + &quot;:\\d+:\\d+&quot;);
</del><ins>+        // Escape the URL per http://stackoverflow.com/questions/3561493/is-there-a-regexp-escape-function-in-javascript
+        // in case it contains RegExp characters.
+        var script_url = get_script_url();
+        var re_text = script_url ? script_url.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&amp;') : &quot;\\btestharness.js&quot;;
+        var re = new RegExp(re_text + &quot;:\\d+:\\d+&quot;);
</ins><span class="cx"> 
</span><span class="cx">         // Some browsers include a preamble that specifies the type of the error object.  Skip this by
</span><span class="cx">         // advancing until we find the first stack frame originating from testharness.js.
</span><span class="lines">@@ -2634,7 +2672,7 @@
</span><span class="cx"> 
</span><span class="cx">     var tests = new Tests();
</span><span class="cx"> 
</span><del>-    addEventListener(&quot;error&quot;, function(e) {
</del><ins>+    var error_handler = function(e) {
</ins><span class="cx">         if (tests.file_is_test) {
</span><span class="cx">             var test = tests.tests[0];
</span><span class="cx">             if (test.phase &gt;= test.phases.HAS_RESULT) {
</span><span class="lines">@@ -2649,8 +2687,11 @@
</span><span class="cx">             tests.status.message = e.message;
</span><span class="cx">             tests.status.stack = e.stack;
</span><span class="cx">         }
</span><del>-    });
</del><ins>+    };
</ins><span class="cx"> 
</span><ins>+    addEventListener(&quot;error&quot;, error_handler, false);
+    addEventListener(&quot;unhandledrejection&quot;, function(e){ error_handler(e.reason); }, false);
+
</ins><span class="cx">     test_environment.on_tests_ready();
</span><span class="cx"> 
</span><span class="cx"> })();
</span></span></pre></div>
<a id="trunkLayoutTestsstreamsshadowingPromiseexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/streams/shadowing-Promise-expected.txt (212146 => 212147)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/streams/shadowing-Promise-expected.txt        2017-02-10 21:34:27 UTC (rev 212146)
+++ trunk/LayoutTests/streams/shadowing-Promise-expected.txt        2017-02-10 21:51:44 UTC (rev 212147)
</span><span class="lines">@@ -9,5 +9,4 @@
</span><span class="cx"> PASS Streams should not directly use Number and related methods 
</span><span class="cx"> PASS Streams should not directly use ReadableStream public APIs 
</span><span class="cx"> PASS Streams should not directly use ReadableStreamDefaultReader read public API 
</span><del>-PASS Streams should not directly use array public APIs 
</del><span class="cx"> 
</span></span></pre></div>
<a id="trunkLayoutTestsstreamsshadowingPromisehtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/streams/shadowing-Promise.html (212146 => 212147)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/streams/shadowing-Promise.html        2017-02-10 21:34:27 UTC (rev 212146)
+++ trunk/LayoutTests/streams/shadowing-Promise.html        2017-02-10 21:51:44 UTC (rev 212147)
</span><span class="lines">@@ -149,58 +149,4 @@
</span><span class="cx">         assert_unreached(&quot;test should not throw&quot;);
</span><span class="cx">     }
</span><span class="cx"> }, 'Streams should not directly use ReadableStreamDefaultReader read public API');
</span><del>-
-promise_test(function() {
-    const ArrayPushBackup = Array.prototype.push;
-    const ArrayShiftBackup = Array.prototype.shift;
-
-    // Use of testing variable to try not messing up testharness.js code.
-    // FIXME: this approach is far from perfect: push is used in case an assert fails.
-    // But cleanTest will not be called and we may end-up mask the real assertion failure by below assert_unreached messages.
-    // We might want to either improve testharness.js or  move these tests out of testharness.js.
-    let testing = true;
-    Array.prototype.push = function() {
-        if (testing) {
-            testing = false;
-            assert_unreached(&quot;Array.prototype.push called&quot;);
-        }
-        return ArrayPushBackup.apply(this, arguments);
-    }
-
-    Array.prototype.shift = function() {
-        if (testing) {
-            testing = false;
-            assert_unreached(&quot;Array.prototype.shift called&quot;);
-        }
-        return ArrayShiftBackup.call(this, arguments);
-    }
-
-    function cleanTest() {
-        Array.prototype.push = ArrayPushBackup;
-        Array.prototype.shift = ArrayShiftBackup;
-    }
-    try {
-        let _controller;
-        const reader = new ReadableStream({
-            start: function(controller) {
-                _controller = controller;
-            }
-        }).getReader();
-        // checking whether pushing/shifting pending read promises is shielded.
-        const readPromise = reader.read().then(function(result) {
-            assert_equals(result.value, &quot;half baked potato&quot;);
-            // checking whether pushing/shifting enqueued values is shielded.
-            _controller.enqueue(&quot;fully baked potato&quot;);
-            return reader.read().then(function(result) {
-                assert_equals(result.value, &quot;fully baked potato&quot;);
-                cleanTest();
-            }, cleanTest);
-        }, cleanTest);
-        _controller.enqueue(&quot;half baked potato&quot;);
-        return readPromise;
-    } catch (error) {
-        cleanTest();
-        return Promise.reject(error);
-    }
-}, 'Streams should not directly use array public APIs');
</del><span class="cx"> &lt;/script&gt;
</span></span></pre></div>
<a id="trunkLayoutTestsstreamsstreamspublicarrayapiexpectedtxt"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/streams/streams-public-array-api-expected.txt (0 => 212147)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/streams/streams-public-array-api-expected.txt                                (rev 0)
+++ trunk/LayoutTests/streams/streams-public-array-api-expected.txt        2017-02-10 21:51:44 UTC (rev 212147)
</span><span class="lines">@@ -0,0 +1,11 @@
</span><ins>+Streams should not directly use array public APIs
+
+On success, you will see a series of &quot;PASS&quot; messages, followed by &quot;TEST COMPLETE&quot;.
+
+
+PASS result.value is &quot;half baked potato&quot;
+PASS result.value is &quot;fully baked potato&quot;
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
</ins></span></pre></div>
<a id="trunkLayoutTestsstreamsstreamspublicarrayapihtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/streams/streams-public-array-api.html (0 => 212147)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/streams/streams-public-array-api.html                                (rev 0)
+++ trunk/LayoutTests/streams/streams-public-array-api.html        2017-02-10 21:51:44 UTC (rev 212147)
</span><span class="lines">@@ -0,0 +1,52 @@
</span><ins>+&lt;!DOCTYPE html&gt;
+&lt;body&gt;
+&lt;script src=&quot;../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
+&lt;script&gt;
+    description(&quot;Streams should not directly use array public APIs&quot;);
+    jsTestIsAsync = true;
+
+    const ArrayPushBackup = Array.prototype.push;
+    const ArrayShiftBackup = Array.prototype.shift;
+
+    Array.prototype.push = function() {
+        testFailed(&quot;Array.prototype.push called&quot;);
+    }
+
+    Array.prototype.shift = function() {
+        testFailed(&quot;Array.prototype.shift called&quot;);
+    }
+
+    function cleanAndFinishTest() {
+        Array.prototype.push = ArrayPushBackup;
+        Array.prototype.shift = ArrayShiftBackup;
+        finishJSTest();
+    }
+
+    try {
+        let _controller;
+        const reader = new ReadableStream({
+            start: function(controller) {
+                _controller = controller;
+            }
+        }).getReader();
+
+        // checking whether pushing/shifting pending read promises is shielded.
+        const readPromise = reader.read().then(function(_result) {
+            result = _result;
+            shouldBeEqualToString(&quot;result.value&quot;, &quot;half baked potato&quot;);
+            // checking whether pushing/shifting enqueued values is shielded.
+            _controller.enqueue(&quot;fully baked potato&quot;);
+            return reader.read().then(function(_result) {
+                result = _result;
+                shouldBeEqualToString(&quot;result.value&quot;, &quot;fully baked potato&quot;);
+                cleanAndFinishTest();
+            }, cleanAndFinishTest);
+        }, cleanAndFinishTest);
+        _controller.enqueue(&quot;half baked potato&quot;);
+    } catch (error) {
+        testFailed(&quot;Exception thrown: &quot; + error);
+        cleanAndFinishTest();
+    }
+&lt;/script&gt;
+&lt;script src=&quot;../resources/js-test-post.js&quot;&gt;&lt;/script&gt;
+&lt;/body&gt;
</ins></span></pre>
</div>
</div>

</body>
</html>