Commit 7988aacc authored by horo@chromium.org's avatar horo@chromium.org

Re-enable iframe load failure tests in fetch-request-redirect.html.

We can't detect the iframe load failure without timeout.
So this CL adds timeout_enabled flag to iframe_test() and set it only for failure tests.

BUG=522587

Review URL: https://codereview.chromium.org/1293023003

git-svn-id: svn://svn.chromium.org/blink/trunk@200910 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 7fd0d339
...@@ -18,11 +18,21 @@ function assert_rejects(promise, description) { ...@@ -18,11 +18,21 @@ function assert_rejects(promise, description) {
function() {}); function() {});
} }
function iframe_test(url) { function iframe_test(url, timeout_enabled) {
return new Promise(function(resolve, reject) { return new Promise(function(resolve, reject) {
var frame = document.createElement('iframe'); var frame = document.createElement('iframe');
frame.src = url; frame.src = url;
if (timeout_enabled) {
// We can't catch the network error on iframe. So we use the timer for
// failure detection.
var timer = setTimeout(function() {
reject(new Error('iframe load timeout'));
frame.remove();
}, 1000);
}
frame.onload = function() { frame.onload = function() {
if (timeout_enabled)
clearTimeout(timer);
if (frame.contentDocument.body.textContent == 'Hello world\n') if (frame.contentDocument.body.textContent == 'Hello world\n')
resolve(); resolve();
else else
...@@ -146,23 +156,20 @@ promise_test(function(t) { ...@@ -146,23 +156,20 @@ promise_test(function(t) {
'&redirect-mode=follow'), '&redirect-mode=follow'),
'Redirected iframe loading with Request.redirect=follow should'+ 'Redirected iframe loading with Request.redirect=follow should'+
' succeed.'), ' succeed.'),
/*
TODO(horo): iframe load failure detection is unreliable.
Rework these. crbug.com/522587
assert_rejects( assert_rejects(
iframe_test(SCOPE + '?url=' + iframe_test(SCOPE + '?url=' +
encodeURIComponent(REDIRECT_TO_HTML_URL) + encodeURIComponent(REDIRECT_TO_HTML_URL) +
'&redirect-mode=error'), '&redirect-mode=error',
true /* timeout_enabled */),
'Redirected iframe loading with Request.redirect=error should '+ 'Redirected iframe loading with Request.redirect=error should '+
'fail.'), 'fail.'),
assert_resolves( assert_resolves(
iframe_test(SCOPE + '?url=' + iframe_test(SCOPE + '?url=' +
encodeURIComponent(REDIRECT_TO_HTML_URL) + encodeURIComponent(REDIRECT_TO_HTML_URL) +
'&redirect-mode=manual'), '&redirect-mode=manual',
true /* timeout_enabled */),
'Redirected iframe loading with Request.redirect=manual should'+ 'Redirected iframe loading with Request.redirect=manual should'+
' succeed.'), ' succeed.'),
*/
]); ]);
}) })
.then(function() { .then(function() {
......
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