зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1450358
P1 Add an event listener runtime leak check for XHR. r=baku
This commit is contained in:
Родитель
5e3b64d3ec
Коммит
720c0d53fb
|
@ -64,6 +64,8 @@ support-files =
|
|||
iframe_sync_xhr_unload.html
|
||||
empty.html
|
||||
file_sync_xhr_document_write_with_iframe.html
|
||||
slow.sjs
|
||||
!/dom/events/test/event_leak_utils.js
|
||||
|
||||
[test_bug1300552.html]
|
||||
[test_html_in_xhr.html]
|
||||
|
@ -114,3 +116,4 @@ support-files = test_XHR_timeout.js
|
|||
[test_XHRSendData.html]
|
||||
[test_sync_xhr_document_write_with_iframe.html]
|
||||
[test_nestedSyncXHR.html]
|
||||
[test_event_listener_leaks.html]
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
function handleRequest(request, response)
|
||||
{
|
||||
response.processAsync();
|
||||
|
||||
timer = Components.classes["@mozilla.org/timer;1"].
|
||||
createInstance(Components.interfaces.nsITimer);
|
||||
timer.init(function() {
|
||||
response.write("Here the content. But slowly.");
|
||||
response.finish();
|
||||
}, 5000, Components.interfaces.nsITimer.TYPE_ONE_SHOT);
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
<!--
|
||||
Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/
|
||||
-->
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Bug 1450271 - Test XHR event listener leak conditions</title>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script type="text/javascript" src="/tests/dom/events/test/event_leak_utils.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
</head>
|
||||
<body>
|
||||
<p id="display"></p>
|
||||
<script class="testbody" type="text/javascript">
|
||||
// Manipulate XHR. Its important here that we create a
|
||||
// listener callback from the DOM objects back to the frame's global
|
||||
// in order to exercise the leak condition.
|
||||
async function useXHR(contentWindow) {
|
||||
let xhr = new contentWindow.XMLHttpRequest();
|
||||
xhr.onabort = _ => {
|
||||
contentWindow.abortCount += 1;
|
||||
};
|
||||
xhr.onreadystate = _ => {
|
||||
contentWindow.stateCount += 1;
|
||||
};
|
||||
xhr.open("GET", "slow.sjs");
|
||||
}
|
||||
|
||||
async function runTest() {
|
||||
try {
|
||||
await checkForEventListenerLeaks("XHR", useXHR);
|
||||
} catch (e) {
|
||||
ok(false, e);
|
||||
} finally {
|
||||
SimpleTest.finish();
|
||||
}
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
addEventListener("load", runTest, { once: true });
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
|
Загрузка…
Ссылка в новой задаче