https://github.com/web-platform-tests/wpt
Raw File
Tip revision: 21f1c08f6e5d4ead08f51968aa6246b2c54b7f15 authored by Geoffrey Sneddon on 10 April 2018, 07:46:22 UTC
Fix #10388: Make resources/test use the upstream config
Tip revision: 21f1c08
logTest.sub.js
// note, this template substitution is XSS, but no way to avoid it in this framework
var expected_logs = {{GET[logs]}};
var timeout = "{{GET[timeout]}}";
if (timeout == "") {
  timeout = 2;
}

if (expected_logs.length == 0) {
    function log_assert(msg) {
        test(function () { assert_unreached(msg) });
    }
} else {
    var t_log = async_test('Expecting logs: {{GET[logs]}}');
    step_timeout(function() {
      if(t_log.phase != t_log.phases.COMPLETE){
        t_log.step(function () { assert_unreached('Logging timeout, expected logs ' + expected_logs + ' not sent.') });
        t_log.done();
      }
    }, timeout * 1000);
    function log(msg) {
        //cons/**/ole.log(msg);
        t_log.step(function () {
            if (msg.match(/^FAIL/i)) {
                assert_unreached(msg);
                t_log.done();
            }
            for (var i = 0; i < expected_logs.length; i++) {
                if (expected_logs[i] == msg) {
                    assert_true(expected_logs[i] == msg);
                    expected_logs.splice(i, 1);
                    if (expected_logs.length == 0) {
                        t_log.done();
                    }
                    return;
                 }
             }
             assert_unreached('unexpected log: ' + msg);
             t_log.done();
        });
    }
}
back to top