Index: third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/test-helpers.js |
diff --git a/third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/test-helpers.js b/third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/test-helpers.js |
index 65215669d63e267a851f047b4f28bd4b1e3cc650..97138d20e14e7b3b3f08b15fd3fba63b4a667c0e 100644 |
--- a/third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/test-helpers.js |
+++ b/third_party/WebKit/LayoutTests/http/tests/serviceworker/resources/test-helpers.js |
@@ -44,14 +44,19 @@ function unreached_rejection(test, prefix) { |
} |
// Adds an iframe to the document and returns a promise that resolves to the |
-// iframe when it finishes loading. The caller is responsible for removing the |
-// iframe later if needed. |
-function with_iframe(url) { |
+// iframe when it finishes loading. When |reclaim_after_completion| is set to |
+// |IFRAME_RECLAMATION.FALSE|, the caller is responsible for removing the iframe |
+// later. Otherwise, the frame will be removed after all tests are finished. |
+var IFRAME_RECLAMATION = Object.freeze({TRUE: true, FALSE: false}); |
nhiroki
2016/04/07 05:37:18
How about using 'const' keyword instead?
const
falken
2016/04/07 05:47:26
Sorry for more drive-bys, just thought of this. Pa
shimazu (google)
2016/04/07 06:53:55
I think so, and fixed it.
|
+function with_iframe(url, reclaim_after_completion) { |
return new Promise(function(resolve) { |
var frame = document.createElement('iframe'); |
frame.src = url; |
frame.onload = function() { resolve(frame); }; |
document.body.appendChild(frame); |
+ if (typeof reclaim_after_completion === 'undefined' || |
+ reclaim_after_completion === IFRAME_RECLAMATION.TRUE) |
+ add_completion_callback(function() { frame.remove(); }); |
}); |
} |