Commit d10756f1 authored by Glenn Adams's avatar Glenn Adams
Browse files

Populate level 3 data and http tests.

parent 3439ff30
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -8,7 +8,6 @@
    "helpers3": [
        "ProtocolCSP"
    ],
    "crossDomainSupport": true,
    "tests": [
        {
            "name": "ProtocolCSP",
+11 −1
Original line number Diff line number Diff line
@@ -5,5 +5,15 @@
    "local": "rfc2397.txt",
    "dontFetch": true,
    "dontFetchReason": "specification is final",
    "helpers3": []
    "helpers3": [
        "SchemeData"
    ],
    "tests": [
        {
            "name": "SchemeData",
            "helper": "SchemeData",
            "code": "run(t)",
            "async": true
        }
    ]
}
+25 −0
Original line number Diff line number Diff line
"use strict";
function run(t) {
    var defProperties = t.properties.def;
    var e = document.createElement('img');
    e.src = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIAAAABgCAIAAABaGO0eAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAo9JREFUeNrsmuFxgkAQRjWTBmxBS9AStAQtQUrQErAELSGUoCVACVIClmC+4SY7DCqjmZNc4L0fxkGEy75j2T0ZDAD6zND9uV6vxKLt0A+HCEAAAhCAAAQgAAEIQAACEAAIQAAgAAGAAAQAAhAACEAAIAABgAAEAAIQAAhAACAAAYAABIAfAQMT4Ivj8fiL0czn81e//mgA+/1+vV7rgHZkEcdxmqZeRugLd9jPLs2pJEmiKLpcLtWNp9PJXs/n83g8DmrM/gWMRiObfbeBENPpVPvUPtXGu5Pu+fMeDgdF38awXC5drHXeLMtkRadwWzyO0BvX92PnUgZ4MoM9f3BNbfuW8k9RFLUdvkq8jJAUdIfdbufeaOLrHnC7g7aHOfKPbghQkgk80H0RcJu7EdAGVtuYCQS0ilU1uhnUylAEtIEqH/dG0Z9MJlZQIqAlVKRb8SMHixJ1Bv/mHwizD2ggjuO7ixC1m7DuDdrzti0Ipw/oyBVgiShNU0tHIs/z7XarpJQkSZhjDroR0+RtyDmPyiFdB5vNRhFXCpIAl5RWq5VbpCMFvWUp4hFSWE1KzacmBflHl4KiaQ5sxYIqqNUCyVKZytPQuoTuC6gtEIXWKvdCQMgLRL0Q4Gqh2qIFAtpDrUCY0e+OgNlspgqnOtNtWSKKIuvCVBTRiL3AYrFovrW6xir7QTNdjdi0xG2vlj2qhQK8AoIW0LyoadFUiHWbdYHOS2oLD/pUbXCYP5Z14TdhmSiKQkF314FM6FVBd49B6DXcFQiejPvL0PNoIgIQgAAEIAABCEAAAhCAAEAAAgABCAAEIAAQgABAAAIAAQgABCAAEIAAQAACAAEIAAQgABCAAEBABwQA9JtvAQYAjHQPgnvkJhsAAAAASUVORK5CYII=';
    e.onload = t.step_func_done(function(evt) {
        loadComplete(defProperties, e, evt);
    });
    e.onerror = e.onload;
    document.body.appendChild(e);
}
function loadComplete(defProperties, e, evt) {
    var eTarget = evt.target;
    test(function() {
        assert_equals(eTarget, e, 'onload target must be original image element');
    },  defProperties.expandedName + '-target-matches');
    test(function() {
        assert_true('naturalWidth' in eTarget, 'image element must have naturalWidth property');
        assert_equals(eTarget.naturalWidth, 128, 'natural width of loaded image must match');
    },  defProperties.expandedName + '-width-matches');
    test(function() {
        assert_true('naturalHeight' in eTarget, 'image element must have naturalHeight property');
        assert_equals(eTarget.naturalHeight, 96, 'natural height of loaded image must match');
    },  defProperties.expandedName + '-height-matches');
}
+76 −0
Original line number Diff line number Diff line
"use strict";
function run(t) {
    var defProperties = t.properties.def;
    var url = './support/respond.py';
    var xhr = new XMLHttpRequest();
    xhr.open('GET', url, true);
    xhr.onload = t.step_func_done(function() {
        // test original request headers (returned unmodified by responder)
        var response = JSON.parse(xhr.response);
        test(function() {
            assert_true('accept' in response);
        }, defProperties.expandedName + '-test-request-header-accept-present');
        test(function() {
            assert_true('accept-language' in response);
        }, defProperties.expandedName + '-test-request-header-accept-language-present');
        test(function() {
            assert_true('accept-encoding' in response);
        }, defProperties.expandedName + '-test-request-header-accept-encoding-present');
        test(function() {
            assert_true('connection' in response);
        }, defProperties.expandedName + '-test-request-header-connection-present');
        test(function() {
            assert_equals(response['connection'], 'keep-alive');
        }, defProperties.expandedName + '-test-request-header-connection-has-keep-alive');
        test(function() {
            assert_true('host' in response);
        }, defProperties.expandedName + '-test-request-header-host-present');
        test(function() {
            assert_equals(response['host'], location.host);
        }, defProperties.expandedName + '-test-request-header-host-match');
        test(function() {
            assert_true('referer' in response);
        }, defProperties.expandedName + '-test-request-header-referer-present');
        test(function() {
            assert_equals(response['referer'], location.href);
        }, defProperties.expandedName + '-test-request-header-referer-match');
        test(function() {
            assert_true('user-agent' in response);
        }, defProperties.expandedName + '-test-request-header-user-agent-present');
        // test response headers (returned by responder)
        var responseHeaders = getResponseHeaders(xhr);
        test(function() {
            assert_true('content-length' in responseHeaders);
        }, defProperties.expandedName + '-test-response-header-content-length-present');
        test(function() {
            assert_true('content-type' in responseHeaders);
        }, defProperties.expandedName + '-test-response-header-content-type-present');
        test(function() {
            assert_equals(responseHeaders['content-type'], 'application/json');
        }, defProperties.expandedName + '-test-response-header-content-type-match');
        test(function() {
            assert_true('date' in responseHeaders);
        }, defProperties.expandedName + '-test-response-header-date-present');
        test(function() {
            assert_true('server' in responseHeaders);
        }, defProperties.expandedName + '-test-response-header-server-present');
    });
    xhr.onerror = function() {
        assert_unreached('unable to load ' + url);
    };
    xhr.send();
}
function getResponseHeaders(xhr) {
    var headers = xhr.getAllResponseHeaders().split('\u000d\u000a');
    var responseHeaders = {};
    for (var i = 0; i < headers.length; ++i) {
        var header = headers[i];
        if (header.indexOf(':') >= 0) {
            var headerComponents = header.split(':');
            var n = headerComponents[0];
            var v = headerComponents[1];
            responseHeaders[n.toLowerCase().trim()] = v.trim();
        }
    }
    return responseHeaders;
}
+11 −1
Original line number Diff line number Diff line
@@ -5,5 +5,15 @@
    "local": "rfc2616.txt",
    "dontFetch": true,
    "dontFetchReason": "specification is final",
    "helpers3": []
    "helpers3": [
        "SchemeHTTP"
    ],
    "tests": [
        {
            "name": "SchemeHTTP",
            "helper": "SchemeHTTP",
            "code": "run(t)",
            "async": true
        }
    ]
}
Loading