Index: LayoutTests/http/tests/serviceworker/chromium/fetch-script-onerror.html |
diff --git a/LayoutTests/http/tests/serviceworker/chromium/fetch-script-onerror.html b/LayoutTests/http/tests/serviceworker/chromium/fetch-script-onerror.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..e76ad79491a80ae12a03b455a63f84f0f298a66c |
--- /dev/null |
+++ b/LayoutTests/http/tests/serviceworker/chromium/fetch-script-onerror.html |
@@ -0,0 +1,97 @@ |
+<!DOCTYPE html> |
+<title>Service Worker: Check script error sanitization</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> |
+<script> |
+var messageCallback; |
falken
2015/05/26 03:27:41
nit: message_callback
horo
2015/05/26 03:58:41
Done.
|
+var host_info = get_host_info(); |
+ |
+window.addEventListener('message', function(evt) { |
+ messageCallback(evt.data); |
+ }); |
+ |
+function get_script_error(frame, url) { |
+ return new Promise(function(resolve) { |
+ messageCallback = resolve; |
+ frame.contentWindow.postMessage({url: url}, host_info['HTTP_ORIGIN']); |
+ }); |
+} |
+ |
+function check_script_error(frame, url, should_be_sanitized) { |
+ if (should_be_sanitized) { |
+ return get_script_error(frame, url) |
+ .then(function(data) { |
+ assert_equals(data.filename, ''); |
+ assert_equals(data.colno, 0); |
+ assert_equals(data.lineno, 0); |
+ assert_equals(data.message, 'Script error.'); |
+ }); |
+ } else { |
+ return get_script_error(frame, url) |
+ .then(function(data) { |
+ assert_equals(data.filename, url); |
+ assert_equals(data.colno, 1); |
+ assert_equals(data.lineno, 1); |
+ assert_equals(data.message, |
+ 'Uncaught ReferenceError: UndefinedReference is not defined'); |
+ }); |
+ } |
+} |
+ |
+async_test(function(t) { |
+ var SCOPE = 'resources/fetch-script-onerror-iframe.html'; |
+ var WORKER_SCRIPT = 'resources/fetch-script-onerror-worker.js'; |
+ var TARGET_PATH = |
+ '/serviceworker/chromium/resources/fetch-script-onerror.php'; |
+ var SCRIPT_URL = host_info['HTTP_ORIGIN'] + TARGET_PATH; |
+ var REMOTE_SCRIPT_URL = host_info['HTTP_REMOTE_ORIGIN'] + TARGET_PATH; |
+ var frame; |
+ service_worker_unregister_and_register(t, WORKER_SCRIPT, SCOPE) |
+ .then(function(registration) { |
+ return wait_for_state(t, registration.installing, 'activated'); |
+ }) |
+ .then(function() { return with_iframe(SCOPE); }) |
+ .then(function(f) { |
+ frame = f; |
+ return check_script_error(frame, SCRIPT_URL, false); |
+ }) |
+ .then(function() { |
+ return check_script_error(frame, REMOTE_SCRIPT_URL, true); |
+ }) |
+ .then(function() { |
+ return check_script_error( |
+ frame, |
+ host_info['HTTP_ORIGIN'] + '/dummy?mode=cors&url=' + |
+ encodeURIComponent(REMOTE_SCRIPT_URL), |
+ false); |
+ }) |
+ .then(function() { |
+ return check_script_error( |
+ frame, |
+ host_info['HTTP_ORIGIN'] + '/dummy?mode=no-cors&url=' + |
+ encodeURIComponent(REMOTE_SCRIPT_URL), |
+ true); |
+ }) |
+ .then(function() { |
+ return check_script_error( |
+ frame, |
+ host_info['HTTP_REMOTE_ORIGIN'] + '/dummy?mode=cors&url=' + |
+ encodeURIComponent(REMOTE_SCRIPT_URL), |
+ false); |
+ }) |
+ .then(function() { |
+ return check_script_error( |
+ frame, |
+ host_info['HTTP_REMOTE_ORIGIN'] + '/dummy?mode=no-cors&url=' + |
+ encodeURIComponent(REMOTE_SCRIPT_URL), |
+ true); |
+ }) |
+ .then(function() { |
+ frame.remove(); |
+ service_worker_unregister_and_done(t, SCOPE); |
+ }) |
+ .catch(unreached_rejection(t)); |
+ }, 'Check script error sanitization'); |
+</script> |