Commit d10756f1 authored by Glenn Adams's avatar Glenn Adams

Populate level 3 data and http tests.

parent 3439ff30
......@@ -8,7 +8,6 @@
"helpers3": [
"ProtocolCSP"
],
"crossDomainSupport": true,
"tests": [
{
"name": "ProtocolCSP",
......
......@@ -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
}
]
}
"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');
}
"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;
}
......@@ -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
}
]
}
import json
def main(request, response):
response.headers.set("Content-Type", "application/json")
return json.dumps(request.headers)
<!-- Copyright (C) 2014, Cable Television Laboratories, Inc. & Skynav, Inc. -->
<!-- DO NOT EDIT! This test was generated by $(CVP2TS)/tools/level2/generate/generate.js. -->
<!doctype html>
<meta charset='utf-8'>
<title>Test SchemeData</title>
<script src='/resources/testharness.js'></script>
<script src='/resources/testharnessreport.js'></script>
<script src='/tools/common/level3.js'></script>
<script src='./helpers/SchemeData.js'></script>
<script type='text/plain' id='testDef'>
{"name":"SchemeData","helper":"SchemeData","code":"run(t)","async":true}
</script>
<h1>Test SchemeData Support</h1>
<div id='log'></div>
<script>
level3Async('data', JSON.parse(document.getElementById('testDef').textContent), function(t){return run(t);});
</script>
"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');
}
"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;
}
<!-- Copyright (C) 2014, Cable Television Laboratories, Inc. & Skynav, Inc. -->
<!-- DO NOT EDIT! This test was generated by $(CVP2TS)/tools/level2/generate/generate.js. -->
<!doctype html>
<meta charset='utf-8'>
<title>Test SchemeHTTP</title>
<script src='/resources/testharness.js'></script>
<script src='/resources/testharnessreport.js'></script>
<script src='/tools/common/level3.js'></script>
<script src='./helpers/SchemeHTTP.js'></script>
<script type='text/plain' id='testDef'>
{"name":"SchemeHTTP","helper":"SchemeHTTP","code":"run(t)","async":true}
</script>
<h1>Test SchemeHTTP Support</h1>
<div id='log'></div>
<script>
level3Async('http', JSON.parse(document.getElementById('testDef').textContent), function(t){return run(t);});
</script>
import json
def main(request, response):
response.headers.set("Content-Type", "application/json")
return json.dumps(request.headers)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment