Title: [212147] trunk/LayoutTests
Revision
212147
Author
cdu...@apple.com
Date
2017-02-10 13:51:44 -0800 (Fri, 10 Feb 2017)

Log Message

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.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (212146 => 212147)


--- trunk/LayoutTests/ChangeLog	2017-02-10 21:34:27 UTC (rev 212146)
+++ trunk/LayoutTests/ChangeLog	2017-02-10 21:51:44 UTC (rev 212147)
@@ -1,3 +1,28 @@
+2017-02-10  Chris Dumez  <cdu...@apple.com>
+
+        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.
+
 2017-02-10  Ryan Haddad  <ryanhad...@apple.com>
 
         Skip some very slow WebCryptoAPI tests.

Modified: trunk/LayoutTests/media/track/w3c/interfaces/HTMLTrackElement/srclang-expected.txt (212146 => 212147)


--- 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)
@@ -1,9 +1,9 @@
 CONSOLE MESSAGE: line 43: The language contains a null character and is not a valid BCP 47 language tag.
 CONSOLE MESSAGE: line 64: The language ' foo 
 ' is not a valid BCP 47 language tag.
-CONSOLE MESSAGE: line 1380: The language ' foo 
+CONSOLE MESSAGE: line 1409: The language ' foo 
 ' is not a valid BCP 47 language tag.
-CONSOLE MESSAGE: line 1380: The language contains a null character and is not a valid BCP 47 language tag.
+CONSOLE MESSAGE: line 1409: The language contains a null character and is not a valid BCP 47 language tag.
 
 PASS HTMLTrackElement.srclang missing value 
 PASS HTMLTrackElement.srclang empty string content attribute 

Modified: trunk/LayoutTests/media/track/w3c/interfaces/TextTrack/language-expected.txt (212146 => 212147)


--- 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)
@@ -1,4 +1,4 @@
-CONSOLE MESSAGE: line 1380: The language contains a null character and is not a valid BCP 47 language tag.
+CONSOLE MESSAGE: line 1409: The language contains a null character and is not a valid BCP 47 language tag.
 CONSOLE MESSAGE: line 26: The language contains a null character and is not a valid BCP 47 language tag.
 
 PASS TextTrack.language 

Modified: trunk/LayoutTests/resources/testharness.js (212146 => 212147)


--- 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)
@@ -389,7 +389,7 @@
         self.addEventListener("connect",
                 function(message_event) {
                     this_obj._add_message_port(message_event.source);
-                });
+                }, false);
     }
     SharedWorkerTestEnvironment.prototype = Object.create(WorkerTestEnvironment.prototype);
 
@@ -430,7 +430,7 @@
                             this_obj._add_message_port(event.source);
                         }
                     }
-                });
+                }, false);
 
         // The oninstall event is received after the service worker script and
         // all imported scripts have been fetched and executed. It's the
@@ -471,6 +471,11 @@
             self instanceof ServiceWorkerGlobalScope) {
             return new ServiceWorkerTestEnvironment();
         }
+        if ('WorkerGlobalScope' in self &&
+            self instanceof WorkerGlobalScope) {
+            return new DedicatedWorkerTestEnvironment();
+        }
+
         throw new Error("Unsupported test environment");
     }
 
@@ -518,14 +523,18 @@
     function promise_test(func, name, properties) {
         var test = async_test(name, properties);
         // If there is no promise tests queue make one.
-        test.step(function() {
-            if (!tests.promise_tests) {
-                tests.promise_tests = Promise.resolve();
-            }
-        });
+        if (!tests.promise_tests) {
+            tests.promise_tests = Promise.resolve();
+        }
         tests.promise_tests = tests.promise_tests.then(function() {
-            return Promise.resolve(test.step(func, test, test))
-                .then(
+            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(
                     function() {
                         test.done();
                     })
@@ -537,12 +546,13 @@
                         assert(false, "promise_test", null,
                                "Unhandled rejection with value: ${value}", {value:value});
                     }));
+            return donePromise;
         });
     }
 
-    function promise_rejects(test, expected, promise) {
-        return promise.then(test.unreached_func("Should have rejected.")).catch(function(e) {
-            assert_throws(expected, function() { throw e });
+    function promise_rejects(test, expected, promise, description) {
+        return promise.then(test.unreached_func("Should have rejected: " + description)).catch(function(e) {
+            assert_throws(expected, function() { throw e }, description);
         });
     }
 
@@ -579,7 +589,7 @@
         });
 
         for (var i = 0; i < eventTypes.length; i++) {
-            watchedNode.addEventListener(eventTypes[i], eventHandler);
+            watchedNode.addEventListener(eventTypes[i], eventHandler, false);
         }
 
         /**
@@ -604,7 +614,7 @@
 
         function stop_watching() {
             for (var i = 0; i < eventTypes.length; i++) {
-                watchedNode.removeEventListener(eventTypes[i], eventHandler);
+                watchedNode.removeEventListener(eventTypes[i], eventHandler, false);
             }
         };
 
@@ -697,10 +707,17 @@
         // instanceof doesn't work if the node is from another window (like an
         // iframe's contentWindow):
         // http://www.w3.org/Bugs/Public/show_bug.cgi?id=12295
-        if ("nodeType" in object &&
-            "nodeName" in object &&
-            "nodeValue" in object &&
-            "childNodes" in object) {
+        try {
+            var has_node_properties = ("nodeType" in object &&
+                                       "nodeName" in object &&
+                                       "nodeValue" in object &&
+                                       "childNodes" in object);
+        } catch (e) {
+            // We're probably cross-origin, which means we aren't a node
+            return false;
+        }
+
+        if (has_node_properties) {
             try {
                 object.nodeType;
             } catch (e) {
@@ -713,6 +730,44 @@
         return false;
     }
 
+    var replacements = {
+        "0": "0",
+        "1": "x01",
+        "2": "x02",
+        "3": "x03",
+        "4": "x04",
+        "5": "x05",
+        "6": "x06",
+        "7": "x07",
+        "8": "b",
+        "9": "t",
+        "10": "n",
+        "11": "v",
+        "12": "f",
+        "13": "r",
+        "14": "x0e",
+        "15": "x0f",
+        "16": "x10",
+        "17": "x11",
+        "18": "x12",
+        "19": "x13",
+        "20": "x14",
+        "21": "x15",
+        "22": "x16",
+        "23": "x17",
+        "24": "x18",
+        "25": "x19",
+        "26": "x1a",
+        "27": "x1b",
+        "28": "x1c",
+        "29": "x1d",
+        "30": "x1e",
+        "31": "x1f",
+        "0xfffd": "ufffd",
+        "0xfffe": "ufffe",
+        "0xffff": "uffff",
+    };
+
     /*
      * Convert a value to a nice, human-readable string
      */
@@ -734,43 +789,9 @@
         switch (typeof val) {
         case "string":
             val = val.replace("\\", "\\\\");
-            for (var i = 0; i < 32; i++) {
-                var replace = "\\";
-                switch (i) {
-                case 0: replace += "0"; break;
-                case 1: replace += "x01"; break;
-                case 2: replace += "x02"; break;
-                case 3: replace += "x03"; break;
-                case 4: replace += "x04"; break;
-                case 5: replace += "x05"; break;
-                case 6: replace += "x06"; break;
-                case 7: replace += "x07"; break;
-                case 8: replace += "b"; break;
-                case 9: replace += "t"; break;
-                case 10: replace += "n"; break;
-                case 11: replace += "v"; break;
-                case 12: replace += "f"; break;
-                case 13: replace += "r"; break;
-                case 14: replace += "x0e"; break;
-                case 15: replace += "x0f"; break;
-                case 16: replace += "x10"; break;
-                case 17: replace += "x11"; break;
-                case 18: replace += "x12"; break;
-                case 19: replace += "x13"; break;
-                case 20: replace += "x14"; break;
-                case 21: replace += "x15"; break;
-                case 22: replace += "x16"; break;
-                case 23: replace += "x17"; break;
-                case 24: replace += "x18"; break;
-                case 25: replace += "x19"; break;
-                case 26: replace += "x1a"; break;
-                case 27: replace += "x1b"; break;
-                case 28: replace += "x1c"; break;
-                case 29: replace += "x1d"; break;
-                case 30: replace += "x1e"; break;
-                case 31: replace += "x1f"; break;
-                }
-                val = val.replace(RegExp(String.fromCharCode(i), "g"), replace);
+            for (var p in replacements) {
+                var replace = "\\" + replacements[p];
+                val = val.replace(RegExp(String.fromCharCode(p), "g"), replace);
             }
             return '"' + val.replace(/"/g, '\\"') + '"';
         case "boolean":
@@ -818,7 +839,12 @@
 
         /* falls through */
         default:
-            return typeof val + ' "' + truncate(String(val), 60) + '"';
+            try {
+                return typeof val + ' "' + truncate(String(val), 1000) + '"';
+            } catch(e) {
+                return ("[stringifying object threw " + String(e) +
+                        " with type " + String(typeof e) + "]");
+            }
         }
     }
     expose(format_value, "format_value");
@@ -1176,6 +1202,7 @@
                 NO_MODIFICATION_ALLOWED_ERR: 'NoModificationAllowedError',
                 NOT_FOUND_ERR: 'NotFoundError',
                 NOT_SUPPORTED_ERR: 'NotSupportedError',
+                INUSE_ATTRIBUTE_ERR: 'InUseAttributeError',
                 INVALID_STATE_ERR: 'InvalidStateError',
                 SYNTAX_ERR: 'SyntaxError',
                 INVALID_MODIFICATION_ERR: 'InvalidModificationError',
@@ -1202,6 +1229,7 @@
                 NoModificationAllowedError: 7,
                 NotFoundError: 8,
                 NotSupportedError: 9,
+                InUseAttributeError: 10,
                 InvalidStateError: 11,
                 SyntaxError: 12,
                 InvalidModificationError: 13,
@@ -1226,6 +1254,7 @@
                 ReadOnlyError: 0,
                 VersionError: 0,
                 OperationError: 0,
+                NotAllowedError: 0
             };
 
             if (!(name in name_code_map)) {
@@ -1436,7 +1465,7 @@
         var args = Array.prototype.slice.call(arguments, 2);
         return setTimeout(this.step_func(function() {
             return f.apply(test_this, args);
-        }, timeout * tests.timeout_multiplier));
+        }), timeout * tests.timeout_multiplier);
     }
 
     Test.prototype.add_cleanup = function(callback) {
@@ -2442,11 +2471,20 @@
             }
         }
 
+        // 'Error.stack' is not supported in all browsers/versions
+        if (!stack) {
+            return "(Stack trace unavailable)";
+        }
+
         var lines = stack.split("\n");
 
         // Create a pattern to match stack frames originating within testharness.js.  These include the
         // script URL, followed by the line/col (e.g., '/resources/testharness.js:120:21').
-        var re = new RegExp((get_script_url() || "\\btestharness.js") + ":\\d+:\\d+");
+        // 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, '\\$&') : "\\btestharness.js";
+        var re = new RegExp(re_text + ":\\d+:\\d+");
 
         // Some browsers include a preamble that specifies the type of the error object.  Skip this by
         // advancing until we find the first stack frame originating from testharness.js.
@@ -2634,7 +2672,7 @@
 
     var tests = new Tests();
 
-    addEventListener("error", function(e) {
+    var error_handler = function(e) {
         if (tests.file_is_test) {
             var test = tests.tests[0];
             if (test.phase >= test.phases.HAS_RESULT) {
@@ -2649,8 +2687,11 @@
             tests.status.message = e.message;
             tests.status.stack = e.stack;
         }
-    });
+    };
 
+    addEventListener("error", error_handler, false);
+    addEventListener("unhandledrejection", function(e){ error_handler(e.reason); }, false);
+
     test_environment.on_tests_ready();
 
 })();

Modified: trunk/LayoutTests/streams/shadowing-Promise-expected.txt (212146 => 212147)


--- 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)
@@ -9,5 +9,4 @@
 PASS Streams should not directly use Number and related methods 
 PASS Streams should not directly use ReadableStream public APIs 
 PASS Streams should not directly use ReadableStreamDefaultReader read public API 
-PASS Streams should not directly use array public APIs 
 

Modified: trunk/LayoutTests/streams/shadowing-Promise.html (212146 => 212147)


--- 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)
@@ -149,58 +149,4 @@
         assert_unreached("test should not throw");
     }
 }, 'Streams should not directly use ReadableStreamDefaultReader read public API');
-
-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("Array.prototype.push called");
-        }
-        return ArrayPushBackup.apply(this, arguments);
-    }
-
-    Array.prototype.shift = function() {
-        if (testing) {
-            testing = false;
-            assert_unreached("Array.prototype.shift called");
-        }
-        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, "half baked potato");
-            // checking whether pushing/shifting enqueued values is shielded.
-            _controller.enqueue("fully baked potato");
-            return reader.read().then(function(result) {
-                assert_equals(result.value, "fully baked potato");
-                cleanTest();
-            }, cleanTest);
-        }, cleanTest);
-        _controller.enqueue("half baked potato");
-        return readPromise;
-    } catch (error) {
-        cleanTest();
-        return Promise.reject(error);
-    }
-}, 'Streams should not directly use array public APIs');
 </script>

Added: trunk/LayoutTests/streams/streams-public-array-api-expected.txt (0 => 212147)


--- 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)
@@ -0,0 +1,11 @@
+Streams should not directly use array public APIs
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS result.value is "half baked potato"
+PASS result.value is "fully baked potato"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/streams/streams-public-array-api.html (0 => 212147)


--- 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)
@@ -0,0 +1,52 @@
+<!DOCTYPE html>
+<body>
+<script src=""
+<script>
+    description("Streams should not directly use array public APIs");
+    jsTestIsAsync = true;
+
+    const ArrayPushBackup = Array.prototype.push;
+    const ArrayShiftBackup = Array.prototype.shift;
+
+    Array.prototype.push = function() {
+        testFailed("Array.prototype.push called");
+    }
+
+    Array.prototype.shift = function() {
+        testFailed("Array.prototype.shift called");
+    }
+
+    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("result.value", "half baked potato");
+            // checking whether pushing/shifting enqueued values is shielded.
+            _controller.enqueue("fully baked potato");
+            return reader.read().then(function(_result) {
+                result = _result;
+                shouldBeEqualToString("result.value", "fully baked potato");
+                cleanAndFinishTest();
+            }, cleanAndFinishTest);
+        }, cleanAndFinishTest);
+        _controller.enqueue("half baked potato");
+    } catch (error) {
+        testFailed("Exception thrown: " + error);
+        cleanAndFinishTest();
+    }
+</script>
+<script src=""
+</body>
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to