var prefixes = {}; for (var prefix in namespaces) { if (namespaces.hasOwnProperty(prefix)) {
prefixes[namespaces[prefix]] = prefix;
}
}
prefixes[namespaces["mathml"]] = "math";
function format(format_string) { var insertions = Array.prototype.slice.call(arguments, 1); var regexp = /%s/g; var match_count = 0; var rv = format_string.replace(regexp, function(match) { var rv = insertions[match_count];
match_count++; return rv;
}); return rv;
}
function test_serializer(element) {
element.normalize(); var lines = []; function serialize_element(element, indent) { var indent_spaces = (new Array(indent)).join(" "); switch(element.nodeType) { case Node.DOCUMENT_TYPE_NODE: if (element.name) { if (element.publicId || element.systemId) { var publicId = element.publicId ? element.publicId : ""; var systemId = element.systemId ? element.systemId : "";
lines.push(format("|%s%s\" \"%s\">", indent_spaces,
element.name, publicId, systemId));
} else {
lines.push(format("|%s", indent_spaces,
element.name));
}
} else {
lines.push(format("|%s", indent_spaces));
} break; case Node.DOCUMENT_NODE:
lines.push("#document"); break; case Node.DOCUMENT_FRAGMENT_NODE:
lines.push("#document-fragment"); break; case Node.COMMENT_NODE:
lines.push(format("|%s", indent_spaces, element.nodeValue)); break; case Node.TEXT_NODE:
lines.push(format("|%s\"%s\"", indent_spaces, element.nodeValue)); break; case Node.ELEMENT_NODE: if (element.getAttribute("data-skip") !== null) { return;
} if (element.namespaceURI !== null && element.namespaceURI !== namespaces.html) { var name = format("%s %s", prefixes[element.namespaceURI],
element.localName);
} else { var name = element.localName;
}
lines.push(format("|%s<%s>", indent_spaces, name));
var attributes = Array.prototype.map.call(
element.attributes, function(attr) { var name = (attr.namespaceURI ? prefixes[attr.namespaceURI] + " " : "") +
attr.localName; return [name, attr.value];
});
attributes.sort(function (a, b) { var x = a[0]; var y = b[0]; if (x === y) { return 0;
} return x > y ? 1 : -1;
});
function parse_query() { var query = location.search.slice(1); var vars = query.split("&"); var fields = vars.map(function (x) { var split = x.split("="); return [split[0], split.slice(1).join("=")];
}); return fields;
}
function get_type() { var run_type = "uri"; var fields = parse_query();
fields.forEach(function(x) { if(x[0] == "run_type") {
run_type = x[1];
}
}); return run_type;
};
var test_in_blob_uri = get_test_func(function (iframe, uri_encoded_input, t) { var b = new Blob([decodeURIComponent(uri_encoded_input)], { type: "text/html" }); var blobURL = URL.createObjectURL(b);
iframe.src = blobURL;
t.add_cleanup(function() {
URL.revokeObjectURL(blobURL);
});
});
var test_document_write = get_test_func(function(iframe, uri_encoded_input, t) {
iframe.contentDocument.open(); var input = decodeURIComponent(uri_encoded_input);
iframe.contentDocument.write(input);
iframe.contentDocument.close();
});
var test_document_write_single = get_test_func(function(iframe, uri_encoded_input, t) {
iframe.contentDocument.open(); var input = decodeURIComponent(uri_encoded_input); for (var i=0; i< input.length; i++) {
iframe.contentDocument.write(input[i]);
}
iframe.contentDocument.close();
});
function get_test_func(inject_func) { function test_func(iframe, t, test_id, uri_encoded_input, escaped_expected) { var expected = decodeURIComponent(escaped_expected);
current_tests[iframe.id] = {test_id:test_id,
uri_encoded_input:uri_encoded_input,
expected:expected,
actual:null
};
function convert_innerHTML(serialized_dom) { var lines = serialized_dom.split("\n");
assert_not_equals(lines[0], "", "template is never the innerHTML context object");
lines[0] = "#document"; return lines.join("\n");
}
function print_diffs(test_id, uri_encoded_input, expected, actual, container) {
container = container ? container : null; if (actual) { var diffs = mark_diffs(expected, actual); var expected_text = diffs[0]; var actual_text = diffs[1];
} else { var expected_text = expected; var actual_text = "";
}
var diff_dom = template.render(tmpl, {test_id:test_id, container:container});
document.body.appendChild(diff_dom);
}
var current_tests = {}; var iframe_map = {};
function init_tests(test_type) { var test_func = null; var test_funcs = { "write":test_document_write, "write_single":test_document_write_single, "uri":test_in_blob_uri, "innerHTML":test_fragment
}; var tests_started = 0; var tests_complete = 0;
//Create the iframes we will use to test //in the innerHTML case these are not actually used //but it is convenient to reuse the same code for (var i=0; i<num_iframes; i++) { var iframe = document.createElement("iframe");
iframe.id = "iframe_" + i;
iframe.style.display = "none";
document.body.appendChild(iframe);
}
},
{explicit_done:true});
function test_next(iframe) { var test_id = order[tests_started];
tests_started++; var x = tests[test_id]; var t = x[0];
iframe_map[t.name] = iframe.id;
step_timeout(function() {
t.step(function() { var string_uri_encoded_input = x[1]; var string_escaped_expected = x[2]; if (test_type === "innerHTML") { var container = x[3];
}
test_func(iframe, t, test_id, string_uri_encoded_input, string_escaped_expected,
container);
});
}, 0);
}
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.21Bemerkung:
Wie Sie bei der Firma Beratungs- und Dienstleistungen beauftragen können
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.