Changeset 212147 in webkit


Ignore:
Timestamp:
Feb 10, 2017, 1:51:44 PM (9 years ago)
Author:
Chris Dumez
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.
Location:
trunk/LayoutTests
Files:
2 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r212141 r212147  
     12017-02-10  Chris Dumez  <cdumez@apple.com>
     2
     3        Update LayoutTests/resources/testharness.js
     4        https://bugs.webkit.org/show_bug.cgi?id=168100
     5
     6        Reviewed by Youenn Fablet.
     7
     8        Update LayoutTests/resources/testharness.js to match the web-platform-tests
     9        one landed in r211930.
     10
     11        * media/track/w3c/interfaces/HTMLTrackElement/srclang-expected.txt:
     12        * media/track/w3c/interfaces/TextTrack/language-expected.txt:
     13        * resources/testharness.js:
     14        (SharedWorkerTestEnvironment):
     15        (ServiceWorkerTestEnvironment):
     16        (create_test_environment):
     17        (promise_test):
     18        (EventWatcher):
     19        (is_node):
     20        (format_value):
     21        * streams/shadowing-Promise-expected.txt:
     22        * streams/shadowing-Promise.html:
     23        * streams/streams-public-array-api-expected.txt: Added.
     24        * streams/streams-public-array-api.html: Added.
     25
    1262017-02-10  Ryan Haddad  <ryanhaddad@apple.com>
    227
  • trunk/LayoutTests/media/track/w3c/interfaces/HTMLTrackElement/srclang-expected.txt

    r210280 r212147  
    22CONSOLE MESSAGE: line 64: The language ' foo
    33' is not a valid BCP 47 language tag.
    4 CONSOLE MESSAGE: line 1380: The language ' foo
     4CONSOLE MESSAGE: line 1409: The language ' foo
    55' is not a valid BCP 47 language tag.
    6 CONSOLE MESSAGE: line 1380: The language contains a null character and is not a valid BCP 47 language tag.
     6CONSOLE MESSAGE: line 1409: The language contains a null character and is not a valid BCP 47 language tag.
    77
    88PASS HTMLTrackElement.srclang missing value
  • trunk/LayoutTests/media/track/w3c/interfaces/TextTrack/language-expected.txt

    r210280 r212147  
    1 CONSOLE MESSAGE: line 1380: The language contains a null character and is not a valid BCP 47 language tag.
     1CONSOLE MESSAGE: line 1409: The language contains a null character and is not a valid BCP 47 language tag.
    22CONSOLE MESSAGE: line 26: The language contains a null character and is not a valid BCP 47 language tag.
    33
  • trunk/LayoutTests/resources/testharness.js

    r194136 r212147  
    390390                function(message_event) {
    391391                    this_obj._add_message_port(message_event.source);
    392                 });
     392                }, false);
    393393    }
    394394    SharedWorkerTestEnvironment.prototype = Object.create(WorkerTestEnvironment.prototype);
     
    431431                        }
    432432                    }
    433                 });
     433                }, false);
    434434
    435435        // The oninstall event is received after the service worker script and
     
    472472            return new ServiceWorkerTestEnvironment();
    473473        }
     474        if ('WorkerGlobalScope' in self &&
     475            self instanceof WorkerGlobalScope) {
     476            return new DedicatedWorkerTestEnvironment();
     477        }
     478
    474479        throw new Error("Unsupported test environment");
    475480    }
     
    519524        var test = async_test(name, properties);
    520525        // If there is no promise tests queue make one.
    521         test.step(function() {
    522             if (!tests.promise_tests) {
    523                 tests.promise_tests = Promise.resolve();
    524             }
    525         });
     526        if (!tests.promise_tests) {
     527            tests.promise_tests = Promise.resolve();
     528        }
    526529        tests.promise_tests = tests.promise_tests.then(function() {
    527             return Promise.resolve(test.step(func, test, test))
    528                 .then(
     530            var donePromise = new Promise(function(resolve) {
     531                test.add_cleanup(resolve);
     532            });
     533            var promise = test.step(func, test, test);
     534            test.step(function() {
     535                assert_not_equals(promise, undefined);
     536            });
     537            Promise.resolve(promise).then(
    529538                    function() {
    530539                        test.done();
     
    538547                               "Unhandled rejection with value: ${value}", {value:value});
    539548                    }));
     549            return donePromise;
    540550        });
    541551    }
    542552
    543     function promise_rejects(test, expected, promise) {
    544         return promise.then(test.unreached_func("Should have rejected.")).catch(function(e) {
    545             assert_throws(expected, function() { throw e });
     553    function promise_rejects(test, expected, promise, description) {
     554        return promise.then(test.unreached_func("Should have rejected: " + description)).catch(function(e) {
     555            assert_throws(expected, function() { throw e }, description);
    546556        });
    547557    }
     
    580590
    581591        for (var i = 0; i < eventTypes.length; i++) {
    582             watchedNode.addEventListener(eventTypes[i], eventHandler);
     592            watchedNode.addEventListener(eventTypes[i], eventHandler, false);
    583593        }
    584594
     
    605615        function stop_watching() {
    606616            for (var i = 0; i < eventTypes.length; i++) {
    607                 watchedNode.removeEventListener(eventTypes[i], eventHandler);
     617                watchedNode.removeEventListener(eventTypes[i], eventHandler, false);
    608618            }
    609619        };
     
    698708        // iframe's contentWindow):
    699709        // http://www.w3.org/Bugs/Public/show_bug.cgi?id=12295
    700         if ("nodeType" in object &&
    701             "nodeName" in object &&
    702             "nodeValue" in object &&
    703             "childNodes" in object) {
     710        try {
     711            var has_node_properties = ("nodeType" in object &&
     712                                       "nodeName" in object &&
     713                                       "nodeValue" in object &&
     714                                       "childNodes" in object);
     715        } catch (e) {
     716            // We're probably cross-origin, which means we aren't a node
     717            return false;
     718        }
     719
     720        if (has_node_properties) {
    704721            try {
    705722                object.nodeType;
     
    714731    }
    715732
     733    var replacements = {
     734        "0": "0",
     735        "1": "x01",
     736        "2": "x02",
     737        "3": "x03",
     738        "4": "x04",
     739        "5": "x05",
     740        "6": "x06",
     741        "7": "x07",
     742        "8": "b",
     743        "9": "t",
     744        "10": "n",
     745        "11": "v",
     746        "12": "f",
     747        "13": "r",
     748        "14": "x0e",
     749        "15": "x0f",
     750        "16": "x10",
     751        "17": "x11",
     752        "18": "x12",
     753        "19": "x13",
     754        "20": "x14",
     755        "21": "x15",
     756        "22": "x16",
     757        "23": "x17",
     758        "24": "x18",
     759        "25": "x19",
     760        "26": "x1a",
     761        "27": "x1b",
     762        "28": "x1c",
     763        "29": "x1d",
     764        "30": "x1e",
     765        "31": "x1f",
     766        "0xfffd": "ufffd",
     767        "0xfffe": "ufffe",
     768        "0xffff": "uffff",
     769    };
     770
    716771    /*
    717772     * Convert a value to a nice, human-readable string
     
    735790        case "string":
    736791            val = val.replace("\\", "\\\\");
    737             for (var i = 0; i < 32; i++) {
    738                 var replace = "\\";
    739                 switch (i) {
    740                 case 0: replace += "0"; break;
    741                 case 1: replace += "x01"; break;
    742                 case 2: replace += "x02"; break;
    743                 case 3: replace += "x03"; break;
    744                 case 4: replace += "x04"; break;
    745                 case 5: replace += "x05"; break;
    746                 case 6: replace += "x06"; break;
    747                 case 7: replace += "x07"; break;
    748                 case 8: replace += "b"; break;
    749                 case 9: replace += "t"; break;
    750                 case 10: replace += "n"; break;
    751                 case 11: replace += "v"; break;
    752                 case 12: replace += "f"; break;
    753                 case 13: replace += "r"; break;
    754                 case 14: replace += "x0e"; break;
    755                 case 15: replace += "x0f"; break;
    756                 case 16: replace += "x10"; break;
    757                 case 17: replace += "x11"; break;
    758                 case 18: replace += "x12"; break;
    759                 case 19: replace += "x13"; break;
    760                 case 20: replace += "x14"; break;
    761                 case 21: replace += "x15"; break;
    762                 case 22: replace += "x16"; break;
    763                 case 23: replace += "x17"; break;
    764                 case 24: replace += "x18"; break;
    765                 case 25: replace += "x19"; break;
    766                 case 26: replace += "x1a"; break;
    767                 case 27: replace += "x1b"; break;
    768                 case 28: replace += "x1c"; break;
    769                 case 29: replace += "x1d"; break;
    770                 case 30: replace += "x1e"; break;
    771                 case 31: replace += "x1f"; break;
    772                 }
    773                 val = val.replace(RegExp(String.fromCharCode(i), "g"), replace);
     792            for (var p in replacements) {
     793                var replace = "\\" + replacements[p];
     794                val = val.replace(RegExp(String.fromCharCode(p), "g"), replace);
    774795            }
    775796            return '"' + val.replace(/"/g, '\\"') + '"';
     
    819840        /* falls through */
    820841        default:
    821             return typeof val + ' "' + truncate(String(val), 60) + '"';
     842            try {
     843                return typeof val + ' "' + truncate(String(val), 1000) + '"';
     844            } catch(e) {
     845                return ("[stringifying object threw " + String(e) +
     846                        " with type " + String(typeof e) + "]");
     847            }
    822848        }
    823849    }
     
    11771203                NOT_FOUND_ERR: 'NotFoundError',
    11781204                NOT_SUPPORTED_ERR: 'NotSupportedError',
     1205                INUSE_ATTRIBUTE_ERR: 'InUseAttributeError',
    11791206                INVALID_STATE_ERR: 'InvalidStateError',
    11801207                SYNTAX_ERR: 'SyntaxError',
     
    12031230                NotFoundError: 8,
    12041231                NotSupportedError: 9,
     1232                InUseAttributeError: 10,
    12051233                InvalidStateError: 11,
    12061234                SyntaxError: 12,
     
    12271255                VersionError: 0,
    12281256                OperationError: 0,
     1257                NotAllowedError: 0
    12291258            };
    12301259
     
    14371466        return setTimeout(this.step_func(function() {
    14381467            return f.apply(test_this, args);
    1439         }, timeout * tests.timeout_multiplier));
     1468        }), timeout * tests.timeout_multiplier);
    14401469    }
    14411470
     
    24432472        }
    24442473
     2474        // 'Error.stack' is not supported in all browsers/versions
     2475        if (!stack) {
     2476            return "(Stack trace unavailable)";
     2477        }
     2478
    24452479        var lines = stack.split("\n");
    24462480
    24472481        // Create a pattern to match stack frames originating within testharness.js.  These include the
    24482482        // script URL, followed by the line/col (e.g., '/resources/testharness.js:120:21').
    2449         var re = new RegExp((get_script_url() || "\\btestharness.js") + ":\\d+:\\d+");
     2483        // Escape the URL per http://stackoverflow.com/questions/3561493/is-there-a-regexp-escape-function-in-javascript
     2484        // in case it contains RegExp characters.
     2485        var script_url = get_script_url();
     2486        var re_text = script_url ? script_url.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&') : "\\btestharness.js";
     2487        var re = new RegExp(re_text + ":\\d+:\\d+");
    24502488
    24512489        // Some browsers include a preamble that specifies the type of the error object.  Skip this by
     
    26352673    var tests = new Tests();
    26362674
    2637     addEventListener("error", function(e) {
     2675    var error_handler = function(e) {
    26382676        if (tests.file_is_test) {
    26392677            var test = tests.tests[0];
     
    26502688            tests.status.stack = e.stack;
    26512689        }
    2652     });
     2690    };
     2691
     2692    addEventListener("error", error_handler, false);
     2693    addEventListener("unhandledrejection", function(e){ error_handler(e.reason); }, false);
    26532694
    26542695    test_environment.on_tests_ready();
  • trunk/LayoutTests/streams/shadowing-Promise-expected.txt

    r203772 r212147  
    1010PASS Streams should not directly use ReadableStream public APIs
    1111PASS Streams should not directly use ReadableStreamDefaultReader read public API
    12 PASS Streams should not directly use array public APIs
    1312
  • trunk/LayoutTests/streams/shadowing-Promise.html

    r203772 r212147  
    150150    }
    151151}, 'Streams should not directly use ReadableStreamDefaultReader read public API');
    152 
    153 promise_test(function() {
    154     const ArrayPushBackup = Array.prototype.push;
    155     const ArrayShiftBackup = Array.prototype.shift;
    156 
    157     // Use of testing variable to try not messing up testharness.js code.
    158     // FIXME: this approach is far from perfect: push is used in case an assert fails.
    159     // But cleanTest will not be called and we may end-up mask the real assertion failure by below assert_unreached messages.
    160     // We might want to either improve testharness.js or  move these tests out of testharness.js.
    161     let testing = true;
    162     Array.prototype.push = function() {
    163         if (testing) {
    164             testing = false;
    165             assert_unreached("Array.prototype.push called");
    166         }
    167         return ArrayPushBackup.apply(this, arguments);
    168     }
    169 
    170     Array.prototype.shift = function() {
    171         if (testing) {
    172             testing = false;
    173             assert_unreached("Array.prototype.shift called");
    174         }
    175         return ArrayShiftBackup.call(this, arguments);
    176     }
    177 
    178     function cleanTest() {
    179         Array.prototype.push = ArrayPushBackup;
    180         Array.prototype.shift = ArrayShiftBackup;
    181     }
    182     try {
    183         let _controller;
    184         const reader = new ReadableStream({
    185             start: function(controller) {
    186                 _controller = controller;
    187             }
    188         }).getReader();
    189         // checking whether pushing/shifting pending read promises is shielded.
    190         const readPromise = reader.read().then(function(result) {
    191             assert_equals(result.value, "half baked potato");
    192             // checking whether pushing/shifting enqueued values is shielded.
    193             _controller.enqueue("fully baked potato");
    194             return reader.read().then(function(result) {
    195                 assert_equals(result.value, "fully baked potato");
    196                 cleanTest();
    197             }, cleanTest);
    198         }, cleanTest);
    199         _controller.enqueue("half baked potato");
    200         return readPromise;
    201     } catch (error) {
    202         cleanTest();
    203         return Promise.reject(error);
    204     }
    205 }, 'Streams should not directly use array public APIs');
    206152</script>
Note: See TracChangeset for help on using the changeset viewer.