Commit 0059e4c6 authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

[Zelenium] Support UTF-8 HTML to 'Store the test HTML as a dataURL in case of error'.

Still non-UTF-8 bytes will be lost, but better than nothing for debugging purpose.
parent a386c83d
......@@ -503,15 +503,14 @@ objectExtend(HtmlTestCaseRow.prototype, {
// Store the test HTML as a dataURL to ease debugging from posted test results
// This code should be synchronous (no Blob asDataURL method for example)
var aElement = this.trElement.ownerDocument.createElement("a");
aElement.textContent = ' (HTML)'
try {
aElement.href = 'data:text/html;base64,' + btoa(sel$('selenium_myiframe').contentWindow.document.body.innerHTML);
this.trElement.cells[2].appendChild(aElement);
} catch (error) {
// btoa will fail with unicode character
// Do not report HTML error in such case, until a cleaner dataURL is implemented
;
aElement.textContent = ' (HTML)';
function b64EncodeUnicode(str) {
return btoa(encodeURIComponent(str).replace(/%([0-9A-F]{2})/g, function(match, p1) {
return String.fromCharCode('0x' + p1);
}));
}
aElement.href = 'data:text/html;charset=utf-8;base64,' + b64EncodeUnicode(sel$('selenium_myiframe').contentWindow.document.body.innerHTML);
this.trElement.cells[2].appendChild(aElement);
},
setMessage: function(message) {
......
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