Commit 0238c6b5 authored by Joey Arhar's avatar Joey Arhar Committed by Commit Bot

[DevTools] Fix request preview for URI encoded html

Bug: 895081
Change-Id: I49c6131e1cc432e470e4b04353282d3ebebcb063
Reviewed-on: https://chromium-review.googlesource.com/c/1286758Reviewed-by: default avatarDmitry Gozman <dgozman@chromium.org>
Commit-Queue: Joey Arhar <jarhar@chromium.org>
Cr-Commit-Position: refs/heads/master@{#601792}
parent 395516be
Verifies that RequestHTMLView's iframe src is URI encoded
iframe.src: data:text/html,%3Cbody%3E%3Cp%3Ehello%20world!%3Cp%3E%253Cp%253EURI%2520encoded%2520tag!%253C%252Fp%253E%3C/body%3E
decoded iframe.src: data:text/html,<body><p>hello world!<p>%3Cp%3EURI%20encoded%20tag!%3C%2Fp%3E</body>
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
(async function() {
TestRunner.addResult(`Verifies that RequestHTMLView's iframe src is URI encoded`);
await TestRunner.loadModule('network_test_runner');
await TestRunner.showPanel('network');
const dataUrl = `data:text/html,<body><p>hello world!<p>%3Cp%3EURI%20encoded%20tag!%3C%2Fp%3E</body>`;
const requestHtmlView = new Network.RequestHTMLView(dataUrl);
requestHtmlView.wasShown();
const iframe = requestHtmlView.contentElement.firstChild;
TestRunner.addResult('iframe.src: ' + iframe.src);
TestRunner.addResult('decoded iframe.src: ' + decodeURIComponent(iframe.src));
TestRunner.completeTest();
})();
......@@ -63,7 +63,7 @@ Network.RequestHTMLView = class extends UI.VBox {
const iframe = createElement('iframe');
iframe.className = 'html-preview-frame';
iframe.setAttribute('sandbox', ''); // Forbid to run JavaScript and set unique origin.
iframe.setAttribute('src', this._dataURL);
iframe.setAttribute('src', encodeURI(this._dataURL));
iframe.setAttribute('tabIndex', -1);
this.contentElement.appendChild(iframe);
}
......
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