Index: LayoutTests/http/tests/serviceworker/registration-stress.html |
diff --git a/LayoutTests/http/tests/serviceworker/registration-stress.html b/LayoutTests/http/tests/serviceworker/registration-stress.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..6269e3a0c54befce24236d7b98edbeb0b6c6dee8 |
--- /dev/null |
+++ b/LayoutTests/http/tests/serviceworker/registration-stress.html |
@@ -0,0 +1,38 @@ |
+<!DOCTYPE html> |
dominicc (has gone to gerrit)
2014/07/16 04:16:04
Let's move this to chromium/ because stress is kin
nhiroki
2014/07/16 06:54:51
Done.
|
+<title>ServiceWorker: registration stress test</title> |
+<script src="../resources/testharness.js"></script> |
+<script src="../resources/testharnessreport.js"></script> |
+<script src="resources/test-helpers.js"></script> |
+<body> |
+<script> |
+async_test(function(t) { |
+ var step = t.step_func.bind(t); |
dominicc (has gone to gerrit)
2014/07/16 04:16:04
Let's indent two spaces, like this:
async_test(fu
nhiroki
2014/07/16 04:29:49
Hmmm... your example (and wiki's examples) has 4-s
nhiroki
2014/07/16 04:42:28
Ah, maybe I got what you mean. I should fix indent
nhiroki
2014/07/16 06:54:51
Done.
|
+ var url = 'resources/worker-no-op.js'; |
+ var frames = []; |
+ |
+ var number_of_workers = 50; |
+ var register_promises = []; |
+ |
+ for (var i = 0; i < number_of_workers; i++) { |
+ var scope = i; |
+ register_promises.push(with_iframe(scope) |
+ .then(step(function(f) { |
+ frames.push(f); |
+ return navigator.serviceWorker.register(url, {scope: scope}); |
+ }))); |
+ } |
+ |
+ Promise.all(register_promises) |
+ .then(step(function(workers) { |
+ var unregister_promises = []; |
+ for (var i = 0; i < number_of_workers; i++) { |
+ frames[i].remove(); |
+ unregister_promises.push( |
dominicc (has gone to gerrit)
2014/07/16 04:16:04
I wonder if you should unregister them all first a
nhiroki
2014/07/16 06:54:51
Done.
|
+ navigator.serviceWorker.unregister(workers[i].scope)); |
dominicc (has gone to gerrit)
2014/07/16 04:16:04
I wonder if you should unregister them all first a
|
+ } |
+ return Promise.all(unregister_promises); |
+ })) |
+ .then(step(function() { t.done(); })) |
+ .catch(unreached_rejection(t)); |
+ }, 'Registration: stress test'); |
+</script> |