diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /devtools/shared/heapsnapshot/tests/mochitest | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'devtools/shared/heapsnapshot/tests/mochitest')
5 files changed, 158 insertions, 0 deletions
diff --git a/devtools/shared/heapsnapshot/tests/mochitest/chrome.ini b/devtools/shared/heapsnapshot/tests/mochitest/chrome.ini new file mode 100644 index 000000000..497b6fe37 --- /dev/null +++ b/devtools/shared/heapsnapshot/tests/mochitest/chrome.ini @@ -0,0 +1,8 @@ +[DEFAULT] +tags = devtools devtools-memory +skip-if = os == 'android' +support-files = + +[test_DominatorTree_01.html] +[test_SaveHeapSnapshot.html] + diff --git a/devtools/shared/heapsnapshot/tests/mochitest/mochitest.ini b/devtools/shared/heapsnapshot/tests/mochitest/mochitest.ini new file mode 100644 index 000000000..5e7aa8d10 --- /dev/null +++ b/devtools/shared/heapsnapshot/tests/mochitest/mochitest.ini @@ -0,0 +1,6 @@ +[DEFAULT] +tags = devtools devtools-memory +support-files = + +[test_saveHeapSnapshot_e10s_01.html] + diff --git a/devtools/shared/heapsnapshot/tests/mochitest/test_DominatorTree_01.html b/devtools/shared/heapsnapshot/tests/mochitest/test_DominatorTree_01.html new file mode 100644 index 000000000..1f9d8c080 --- /dev/null +++ b/devtools/shared/heapsnapshot/tests/mochitest/test_DominatorTree_01.html @@ -0,0 +1,37 @@ +<!DOCTYPE HTML> +<html> +<!-- +Sanity test that we can compute dominator trees from a heap snapshot in a web window. +--> +<head> + <meta charset="utf-8"> + <title>ChromeUtils.saveHeapSnapshot test</title> + <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> + <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"> +</head> +<body> +<pre id="test"> +<script> +SimpleTest.waitForExplicitFinish(); +window.onload = function() { + const path = ChromeUtils.saveHeapSnapshot({ runtime: true }); + const snapshot = ChromeUtils.readHeapSnapshot(path); + + const dominatorTree = snapshot.computeDominatorTree(); + ok(dominatorTree); + ok(dominatorTree instanceof DominatorTree); + + let threw = false; + try { + new DominatorTree(); + } catch (e) { + threw = true; + } + ok(threw, "Constructor shouldn't be usable"); + + SimpleTest.finish(); +}; +</script> +</pre> +</body> +</html> diff --git a/devtools/shared/heapsnapshot/tests/mochitest/test_SaveHeapSnapshot.html b/devtools/shared/heapsnapshot/tests/mochitest/test_SaveHeapSnapshot.html new file mode 100644 index 000000000..f150a99c7 --- /dev/null +++ b/devtools/shared/heapsnapshot/tests/mochitest/test_SaveHeapSnapshot.html @@ -0,0 +1,25 @@ +<!DOCTYPE HTML> +<html> +<!-- +Bug 1024774 - Sanity test that we can take a heap snapshot in a web window. +--> +<head> + <meta charset="utf-8"> + <title>ChromeUtils.saveHeapSnapshot test</title> + <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> + <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"> +</head> +<body> +<pre id="test"> +<script> +SimpleTest.waitForExplicitFinish(); +window.onload = function() { + ok(ChromeUtils, "The ChromeUtils interface should be exposed in chrome windows."); + ChromeUtils.saveHeapSnapshot({ runtime: true }); + ok(true, "Should save a heap snapshot and shouldn't throw."); + SimpleTest.finish(); +}; +</script> +</pre> +</body> +</html> diff --git a/devtools/shared/heapsnapshot/tests/mochitest/test_saveHeapSnapshot_e10s_01.html b/devtools/shared/heapsnapshot/tests/mochitest/test_saveHeapSnapshot_e10s_01.html new file mode 100644 index 000000000..15f88f8e0 --- /dev/null +++ b/devtools/shared/heapsnapshot/tests/mochitest/test_saveHeapSnapshot_e10s_01.html @@ -0,0 +1,82 @@ +<!DOCTYPE HTML> +<!-- +Bug 1201597 - Sanity test that we can take a heap snapshot in an e10s child process. +--> +<html> +<head> + <title>saveHeapSnapshot in e10s child processes</title> + <script type="application/javascript" + src="/tests/SimpleTest/SimpleTest.js"> + </script> + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> +</head> +<body> + <script type="application/javascript"> + window.onerror = function (msg, url, line, col, err) { + ok(false, "@" + url + ":" + line + ":" + col + ": " + msg + "\n" + err.stack); + }; + + SimpleTest.waitForExplicitFinish(); + + var childFrameURL = "data:text/html,<!DOCTYPE HTML><html><body></body></html>"; + + // This function is stringified and loaded in the child process as a frame + // script. + function childFrameScript() { + try { + ChromeUtils.saveHeapSnapshot({ runtime: true }); + } catch (err) { + sendAsyncMessage("testSaveHeapSnapshot:error", + { error: err.toString() }); + return; + } + + sendAsyncMessage("testSaveHeapSnapshot:done", {}); + } + + // Kick everything off on load. + window.onload = function () { + info("window.onload fired"); + SpecialPowers.addPermission("browser", true, document); + SpecialPowers.pushPrefEnv({ + "set": [ + ["dom.ipc.browser_frames.oop_by_default", true], + ["dom.mozBrowserFramesEnabled", true], + ["browser.pagethumbnails.capturing_disabled", true] + ] + }, function () { + var iframe = document.createElement("iframe"); + SpecialPowers.wrap(iframe).mozbrowser = true; + iframe.id = "iframe"; + iframe.src = childFrameURL; + + + iframe.addEventListener("mozbrowserloadend", function onLoadEnd() { + iframe.removeEventListener("mozbrowserloadend", onLoadEnd); + info("iframe done loading"); + + var mm = SpecialPowers.getBrowserFrameMessageManager(iframe); + + function onError(e) { + ok(false, e.data.error); + } + mm.addMessageListener("testSaveHeapSnapshot:error", onError); + + mm.addMessageListener("testSaveHeapSnapshot:done", function onMsg() { + mm.removeMessageListener("testSaveHeapSnapshot:done", onMsg); + mm.removeMessageListener("testSaveHeapSnapshot:error", onError); + ok(true, "Saved heap snapshot in child process"); + SimpleTest.finish(); + }); + + info("Loading frame script to save heap snapshot"); + mm.loadFrameScript("data:,(" + encodeURI(childFrameScript.toString()) + ")();", + false); + }); + + info("Loading iframe"); + document.body.appendChild(iframe); + }); + }; + </script> +</window> |