Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(229)

Unified Diff: LayoutTests/fast/serviceworker/access-container-with-invalid-context.html

Issue 217023003: Add null checks in navigator.serviceWorker access to fix possible crash (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: LayoutTests/fast/serviceworker/access-container-with-invalid-context.html
diff --git a/LayoutTests/fast/serviceworker/access-container-with-invalid-context.html b/LayoutTests/fast/serviceworker/access-container-with-invalid-context.html
new file mode 100644
index 0000000000000000000000000000000000000000..1e5b48ca6578bb38de54769948988371b9c5e606
--- /dev/null
+++ b/LayoutTests/fast/serviceworker/access-container-with-invalid-context.html
@@ -0,0 +1,30 @@
+<script src="../../resources/js-test.js"></script>
+<script>
+description("This test checks if accessing navigator.serviceWorker doesn't fail with invalid frame");
+
+if (window.testRunner) {
+ testRunner.dumpAsText();
dominicc (has gone to gerrit) 2014/03/31 04:52:09 I could be wrong, but isn't dumpAsText the default
kinuko 2014/03/31 12:33:05 I removed this as I've converted it to use w3c tes
+ testRunner.setCanOpenWindows();
dominicc (has gone to gerrit) 2014/03/31 04:52:09 Do you need separate windows? Why not just use an
kinuko 2014/03/31 12:33:05 Hmm, on my local env I keep failing to repro the c
+ testRunner.waitUntilDone();
+}
+
+var callbackCount = 0;
+function callback() {
+ ++callbackCount;
+ if (callbackCount == 100) {
+ debug("DONE");
+ testRunner.notifyDone();
+ return;
+ }
+ try {
+ // window.navigator is replaced with a new window's one, which could
+ // be now invalid.
+ var sw = navigator.serviceWorker;
+ } catch (error) {}
+ var w = window.open("x", "y");
+ window.navigator = w.navigator;
+ setTimeout(callback, 1);
+}
+
+setTimeout(callback, 1);
dominicc (has gone to gerrit) 2014/03/31 04:52:09 Why do it 100 times? Do you just need a strategic
kinuko 2014/03/31 12:33:05 Either with gc() or not I can't seem to reliably r
+</script>

Powered by Google App Engine
This is Rietveld 408576698