| <!doctype html> |
| <html> |
| <head> |
| <meta charset="utf8"> |
| <link rel="help" href="https://url.spec.whatwg.org/#dom-urlsearchparams"> |
| <script src="../../../resources/testharness.js"></script> |
| <script src="../../../resources/testharnessreport.js"></script> |
| <script> |
| // This test is Chromium-specific because it involves GC. |
| |
| promise_test(async () => { |
| let params = new URLSearchParams('param0=0¶m1=1'); |
| const seen = []; |
| for (const param of params) { |
| const [key, value] = param; |
| if (key === 'param0') { |
| params = undefined; |
| // It takes two iterations of GC before Oilpan objects are collected. |
| for (let i = 0; i < 2; ++i) { |
| gc(); |
| await new Promise(resolve => setTimeout(resolve, 0)); |
| } |
| } |
| seen.push(key); |
| } |
| assert_array_equals(seen, ['param0', 'param1'], |
| 'both parameter should be seen'); |
| }, 'URLSearchParams should not be garbage collected while iterator exists'); |
| |
| </script> |
| </head> |
| </html> |