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