Commit e438b70b authored by mike's avatar mike Committed by Commit bot

Remove duplicate service worker tests

third_party/WebKit/LayoutTests/http/tests/serviceworker/fetch-frame-resource.html

This test is equivalent to the upstream version.

- third_party/WebKit/LayoutTests/http/tests/serviceworker/fetch-mixed-content-to-inscope.html
- third_party/WebKit/LayoutTests/http/tests/serviceworker/fetch-mixed-content-to-outscope.html

These tests are roughly equivalent to the upstream versions. Because the
upstream versions only differ in the inclusion of additional assertions,
the Chromium-specific versions can be safely removed.

BUG=688116
R=mek@chromium.org

Review-Url: https://codereview.chromium.org/2859653002
Cr-Commit-Position: refs/heads/master@{#469024}
parent 6010ecd2
......@@ -15592,8 +15592,6 @@ crbug.com/591099 http/tests/serviceworker/chromium/sandboxed-iframe-fetch-event.
crbug.com/591099 http/tests/serviceworker/chromium/service-worker-gc.html [ Failure ]
crbug.com/591099 http/tests/serviceworker/chromium/window-close-during-registration.html [ Failure ]
crbug.com/591099 http/tests/serviceworker/chromium.fetch-event-headers.html [ Crash ]
crbug.com/591099 http/tests/serviceworker/fetch-frame-resource.html [ Crash ]
crbug.com/591099 http/tests/serviceworker/fetch-mixed-content-to-inscope.html [ Crash ]
crbug.com/591099 http/tests/serviceworker/fetch-request-fallback.html [ Crash Pass ]
crbug.com/591099 http/tests/serviceworker/fetch-request-xhr.html [ Failure Pass ]
crbug.com/591099 http/tests/serviceworker/fetch-response-taint.html [ Crash Pass ]
<!DOCTYPE html>
<title>Service Worker: Fetch for the frame loading.</title>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<script src="../resources/get-host-info.js"></script>
<script src="resources/test-helpers.js"></script>
<body>
<script>
var worker = 'resources/fetch-rewrite-worker.js';
var path = base_path() + 'resources/fetch-access-control.php';
var host_info = get_host_info();
if (window.testRunner) {
testRunner.setCanOpenWindows();
}
async_test(function(t) {
var scope = 'resources/fetch-frame-resource/frame-basic';
service_worker_unregister_and_register(t, worker, scope)
.then(function(reg) {
return wait_for_state(t, reg.installing, 'activated');
})
.then(function() {
return with_iframe(
scope + '?url=' +
encodeURIComponent(host_info['HTTP_ORIGIN'] + path));
})
.then(function(frame) {
assert_equals(
frame.contentDocument.body.textContent.substr(0, 7),
'report(',
'Basic type response could be loaded in the iframe.');
frame.remove();
return service_worker_unregister_and_done(t, scope);
})
.catch(unreached_rejection(t));
}, 'Basic type response could be loaded in the iframe.');
async_test(function(t) {
var scope = 'resources/fetch-frame-resource/frame-cors';
service_worker_unregister_and_register(t, worker, scope)
.then(function(reg) {
return wait_for_state(t, reg.installing, 'activated');
})
.then(function() {
return with_iframe(
scope + '?mode=cors&url=' +
encodeURIComponent(host_info['HTTP_REMOTE_ORIGIN'] + path +
'?ACAOrigin=' + host_info['HTTP_ORIGIN']));
})
.then(function(frame) {
assert_equals(
frame.contentDocument.body.textContent.substr(0, 7),
'report(',
'CORS type response could be loaded in the iframe.');
frame.remove();
return service_worker_unregister_and_done(t, scope);
})
.catch(unreached_rejection(t));
}, 'CORS type response could be loaded in the iframe.');
async_test(function(t) {
var scope = 'resources/fetch-frame-resource/frame-opaque';
service_worker_unregister_and_register(t, worker, scope)
.then(function(reg) {
return wait_for_state(t, reg.installing, 'activated');
})
.then(function() {
var frame = document.createElement('iframe');
frame.src =
scope + '?mode=no-cors&url=' +
encodeURIComponent(host_info['HTTP_REMOTE_ORIGIN'] + path);
document.body.appendChild(frame);
return new Promise(function(resolve) {
frame.onload = function () { resolve(frame) };
});
})
.then(function(frame) {
assert_throws('SecurityError', _ => {
assert_equals(frame.contentDocument.body.textContent, '');
}, 'Opaque response renders error page in the iframe.');
frame.remove();
return service_worker_unregister_and_done(t, scope);
})
.catch(unreached_rejection(t));
}, 'Opaque type response could not be loaded in the iframe.');
async_test(function(t) {
var scope = 'resources/fetch-frame-resource/window-basic';
service_worker_unregister_and_register(t, worker, scope)
.then(function(reg) {
return wait_for_state(t, reg.installing, 'activated');
})
.then(function() {
return new Promise(function(resolve) {
var win = window.open(
scope + '?url=' +
encodeURIComponent(host_info['HTTP_ORIGIN'] + path));
win.onload = function() { resolve(win); };
});
})
.then(function(win) {
assert_equals(
win.document.body.textContent.substr(0, 7),
'report(',
'Basic type response could be loaded in the new window.');
win.close();
return service_worker_unregister_and_done(t, scope);
})
.catch(unreached_rejection(t));
}, 'Basic type response could be loaded in the new window.');
async_test(function(t) {
var scope = 'resources/fetch-frame-resource/window-cors';
service_worker_unregister_and_register(t, worker, scope)
.then(function(reg) {
return wait_for_state(t, reg.installing, 'activated');
})
.then(function() {
return new Promise(function(resolve) {
var win = window.open(
scope + '?mode=cors&url=' +
encodeURIComponent(host_info['HTTP_REMOTE_ORIGIN'] + path +
'?ACAOrigin=' + host_info['HTTP_ORIGIN']));
win.onload = function() { resolve(win); };
});
})
.then(function(win) {
assert_equals(
win.document.body.textContent.substr(0, 7),
'report(',
'CORS type response could be loaded in the new window.');
win.close();
return service_worker_unregister_and_done(t, scope);
})
.catch(unreached_rejection(t));
}, 'CORS type response could be loaded in the new window.');
async_test(function(t) {
var scope = 'resources/fetch-frame-resource/window-opaque';
service_worker_unregister_and_register(t, worker, scope)
.then(function(reg) {
return wait_for_state(t, reg.installing, 'activated');
})
.then(function() {
return window.open(
scope + '?mode=no-cors&url=' +
encodeURIComponent(host_info['HTTP_REMOTE_ORIGIN'] + path));
})
.then(function(win) {
// Give the window time to load: we won't get any error or load events
// so we'll set a timeout instead:
setTimeout(_ => {
assert_throws('SecurityError', _ => {
assert_equals(win.document.body.textContent, '');
}, 'Opaque response renders error page in the new window.');
win.close();
return service_worker_unregister_and_done(t, scope);
}, 1000);
})
// .catch(unreached_rejection(t));
}, 'Opaque type response could not be loaded in the new window.');
</script>
</body>
<!DOCTYPE html>
<title>Service Worker: Mixed content of fetch()</title>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<script src="../resources/get-host-info.js?pipe=sub"></script>
<script src="resources/test-helpers.js"></script>
<body></body>
<script>
async_test(function(t) {
var host_info = get_host_info();
window.addEventListener('message', t.step_func(on_message), false);
with_iframe(
host_info['HTTPS_ORIGIN'] + base_path() +
'resources/fetch-mixed-content-iframe.html?target=inscope');
function on_message(e) {
assert_equals(e.data.results, 'finish');
t.done();
}
}, 'Verify Mixed content of fetch() in a Service Worker');
</script>
CONSOLE ERROR: Mixed Content: The page at 'https://127.0.0.1:8443/serviceworker/resources/fetch-mixed-content-iframe-inscope-to-outscope.html' was loaded over HTTPS, but requested an insecure image 'http://example.test:8000/serviceworker/resources/fetch-access-control.php?PNGIMAGE'. This request has been blocked; the content must be served over HTTPS.
This is a testharness.js-based test.
PASS Verify Mixed content of fetch() in a Service Worker
Harness: the test ran to completion.
<!DOCTYPE html>
<title>Service Worker: Mixed content of fetch()</title>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<script src="../resources/get-host-info.js?pipe=sub"></script>
<script src="resources/test-helpers.js"></script>
<body></body>
<script>
if (window.testRunner) {
// In Chromium we need to change the setting to disallow displaying insecure
// contents.
testRunner.overridePreference("WebKitStrictMixedContentChecking", true);
}
async_test(function(t) {
var host_info = get_host_info();
window.addEventListener('message', t.step_func(on_message), false);
with_iframe(
host_info['HTTPS_ORIGIN'] + base_path() +
'resources/fetch-mixed-content-iframe.html?target=outscope');
function on_message(e) {
assert_equals(e.data.results, 'finish');
t.done();
}
}, 'Verify Mixed content of fetch() in a Service Worker');
</script>
<script src="../../resources/get-host-info.js?pipe=sub"></script>
<script src="test-helpers.js"></script>
<script>
var image_path = base_path() + 'fetch-access-control.php?PNGIMAGE';
var host_info = get_host_info();
var results = '';
function test1() {
var img = document.createElement('img');
document.body.appendChild(img);
img.onload = function() {
test2();
};
img.onerror = function() {
results += 'FAIL(1)';
test2();
};
img.src = './dummy?url=' +
encodeURIComponent(host_info['HTTPS_ORIGIN'] + image_path);
}
function test2() {
var img = document.createElement('img');
document.body.appendChild(img);
img.onload = function() {
test3();
};
img.onerror = function() {
results += 'FAIL(2)';
test3();
};
img.src = './dummy?mode=no-cors&url=' +
encodeURIComponent(host_info['HTTPS_REMOTE_ORIGIN'] + image_path);
}
function test3() {
var img = document.createElement('img');
document.body.appendChild(img);
img.onload = function() {
results += 'FAIL(3)';
finish();
};
img.onerror = function() {
finish();
};
img.src = './dummy?mode=no-cors&url=' +
encodeURIComponent(host_info['UNAUTHENTICATED_ORIGIN'] + image_path);
}
function finish() {
results += 'finish';
window.parent.postMessage({results: results}, host_info['HTTPS_ORIGIN']);
}
</script>
<body onload='test1();'>
</body>
<script src="../../resources/get-host-info.js?pipe=sub"></script>
<script src="test-helpers.js"></script>
<script>
var image_path = base_path() + 'fetch-access-control.php?PNGIMAGE';
var host_info = get_host_info();
var results = '';
function test1() {
var img = document.createElement('img');
document.body.appendChild(img);
img.onload = function() {
test2();
};
img.onerror = function() {
results += 'FAIL(1)';
test2();
};
img.src = host_info['HTTPS_ORIGIN'] + image_path;
}
function test2() {
var img = document.createElement('img');
document.body.appendChild(img);
img.onload = function() {
test3();
};
img.onerror = function() {
results += 'FAIL(2)';
test3();
};
img.src = host_info['HTTPS_REMOTE_ORIGIN'] + image_path;
}
function test3() {
var img = document.createElement('img');
document.body.appendChild(img);
img.onload = function() {
results += 'FAIL(3)';
test4();
};
img.onerror = function() {
test4();
};
img.src = host_info['UNAUTHENTICATED_ORIGIN'] + image_path;
}
function test4() {
var img = document.createElement('img');
document.body.appendChild(img);
img.onload = function() {
finish();
};
img.onerror = function() {
results += 'FAIL(4)';
finish();
};
img.src = './dummy?generate-png';
}
function finish() {
results += 'finish';
window.parent.postMessage({results: results}, host_info['HTTPS_ORIGIN']);
}
</script>
<body onload='test1();'>
</body>
<!DOCTYPE html>
<script src="../../resources/get-host-info.js?pipe=sub"></script>
<script src="test-helpers.js"></script>
<script>
var params = get_query_params(location.href);
var SCOPE = 'fetch-mixed-content-iframe-inscope-to-' + params['target'] + '.html';
var URL = 'fetch-rewrite-worker.js';
var host_info = get_host_info();
window.addEventListener('message', on_message, false);
navigator.serviceWorker.getRegistration(SCOPE)
.then(function(registration) {
if (registration)
return registration.unregister();
})
.then(function() {
return navigator.serviceWorker.register(URL, {scope: SCOPE});
})
.then(function(registration) {
return new Promise(function(resolve) {
registration.addEventListener('updatefound', function() {
resolve(registration.installing);
});
});
})
.then(function(worker) {
worker.addEventListener('statechange', on_state_change);
})
.catch(function(reason) {
window.parent.postMessage({results: 'FAILURE: ' + reason.message},
host_info['HTTP_ORIGIN']);
});
function on_state_change(event) {
if (event.target.state != 'activated')
return;
var frame = document.createElement('iframe');
frame.src = SCOPE;
document.body.appendChild(frame);
}
function on_message(e) {
navigator.serviceWorker.getRegistration(SCOPE)
.then(function(registration) {
if (registration)
return registration.unregister();
})
.then(function() {
window.parent.postMessage(e.data, host_info['HTTP_ORIGIN']);
})
.catch(function(reason) {
window.parent.postMessage({results: 'FAILURE: ' + reason.message},
host_info['HTTP_ORIGIN']);
});
}
function get_query_params(url) {
var search = (new URL(url)).search;
if (!search) {
return {};
}
var ret = {};
var params = search.substring(1).split('&');
params.forEach(function(param) {
var element = param.split('=');
ret[decodeURIComponent(element[0])] = decodeURIComponent(element[1]);
});
return ret;
}
</script>
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