Bug 1233220 - Add test_awsy_lite mochitest, to track Fennec RSS in perfherder; r=snorp,margaret

--HG--
extra : rebase_source : c3a1a9bd3a1f588a3088aa7e07d26d0e36cea245
This commit is contained in:
Geoff Brown 2016-01-26 10:15:56 -07:00
Родитель fea8607ef9
Коммит 3dab228c75
6 изменённых файлов: 329 добавлений и 0 удалений

Просмотреть файл

@ -6,6 +6,10 @@ support-files =
devicesearch.xml
head.js
head_search.js
memory_page_1.html
memory_page_2.html
memory_page_3.html
memory_page_4.html
session_formdata_sample.html
simpleservice.xml
video_controls.html
@ -16,6 +20,9 @@ support-files =
[test_accounts.html]
[test_android_log.html]
[test_app_constants.html]
[test_awsy_lite.html]
# historically, we only run awsy on opt; gc times out on debug
skip-if = debug
[test_debugger_server.html]
[test_desktop_useragent.html]
[test_device_search_engine.html]

Просмотреть файл

@ -0,0 +1,16 @@
<!DOCTYPE html>
<html>
<head>
<title>Article title</title>
<meta name="description" content="This is the article description." />
</head>
<body>
<header>Site header</header>
<div>
<h1>Article title</h1>
<h2 class="author">by Jane Doe</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec a diam lectus. Sed sit amet ipsum mauris. Maecenas congue ligula ac quam viverra nec consectetur ante hendrerit. Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean ut gravida lorem. Ut turpis felis, pulvinar a semper sed, adipiscing id dolor. Pellentesque auctor nisi id magna consequat sagittis. Curabitur dapibus enim sit amet elit pharetra tincidunt feugiat nisl imperdiet. Ut convallis libero in urna ultrices accumsan. Donec sed odio eros. Donec viverra mi quis quam pulvinar at malesuada arcu rhoncus. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. In rutrum accumsan ultricies. Mauris vitae nisi at sem facilisis semper ac in est.</p>
<p>Vivamus fermentum semper porta. Nunc diam velit, adipiscing ut tristique vitae, sagittis vel odio. Maecenas convallis ullamcorper ultricies. Curabitur ornare, ligula semper consectetur sagittis, nisi diam iaculis velit, id fringilla sem nunc vel mi. Nam dictum, odio nec pretium volutpat, arcu ante placerat erat, non tristique elit urna et turpis. Quisque mi metus, ornare sit amet fermentum et, tincidunt et orci. Fusce eget orci a orci congue vestibulum. Ut dolor diam, elementum et vestibulum eu, porttitor vel elit. Curabitur venenatis pulvinar tellus gravida ornare. Sed et erat faucibus nunc euismod ultricies ut id justo. Nullam cursus suscipit nisi, et ultrices justo sodales nec. Fusce venenatis facilisis lectus ac semper. Aliquam at massa ipsum. Quisque bibendum purus convallis nulla ultrices ultricies. Nullam aliquam, mi eu aliquam tincidunt, purus velit laoreet tortor, viverra pretium nisi quam vitae mi. Fusce vel volutpat elit. Nam sagittis nisi dui.</p>
</div>
</body>
</html>

Просмотреть файл

@ -0,0 +1,16 @@
<!DOCTYPE html>
<html>
<head>
<title>Article title</title>
<meta name="description" content="This is the article description." />
</head>
<body>
<header>Site header</header>
<div>
<h1>Article title</h1>
<h2 class="author">by Jane Doe</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec a diam lectus. Sed sit amet ipsum mauris. Maecenas congue ligula ac quam viverra nec consectetur ante hendrerit. Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean ut gravida lorem. Ut turpis felis, pulvinar a semper sed, adipiscing id dolor. Pellentesque auctor nisi id magna consequat sagittis. Curabitur dapibus enim sit amet elit pharetra tincidunt feugiat nisl imperdiet. Ut convallis libero in urna ultrices accumsan. Donec sed odio eros. Donec viverra mi quis quam pulvinar at malesuada arcu rhoncus. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. In rutrum accumsan ultricies. Mauris vitae nisi at sem facilisis semper ac in est.</p>
<p>Vivamus fermentum semper porta. Nunc diam velit, adipiscing ut tristique vitae, sagittis vel odio. Maecenas convallis ullamcorper ultricies. Curabitur ornare, ligula semper consectetur sagittis, nisi diam iaculis velit, id fringilla sem nunc vel mi. Nam dictum, odio nec pretium volutpat, arcu ante placerat erat, non tristique elit urna et turpis. Quisque mi metus, ornare sit amet fermentum et, tincidunt et orci. Fusce eget orci a orci congue vestibulum. Ut dolor diam, elementum et vestibulum eu, porttitor vel elit. Curabitur venenatis pulvinar tellus gravida ornare. Sed et erat faucibus nunc euismod ultricies ut id justo. Nullam cursus suscipit nisi, et ultrices justo sodales nec. Fusce venenatis facilisis lectus ac semper. Aliquam at massa ipsum. Quisque bibendum purus convallis nulla ultrices ultricies. Nullam aliquam, mi eu aliquam tincidunt, purus velit laoreet tortor, viverra pretium nisi quam vitae mi. Fusce vel volutpat elit. Nam sagittis nisi dui.</p>
</div>
</body>
</html>

Просмотреть файл

@ -0,0 +1,16 @@
<!DOCTYPE html>
<html>
<head>
<title>Article title</title>
<meta name="description" content="This is the article description." />
</head>
<body>
<header>Site header</header>
<div>
<h1>Article title</h1>
<h2 class="author">by Jane Doe</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec a diam lectus. Sed sit amet ipsum mauris. Maecenas congue ligula ac quam viverra nec consectetur ante hendrerit. Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean ut gravida lorem. Ut turpis felis, pulvinar a semper sed, adipiscing id dolor. Pellentesque auctor nisi id magna consequat sagittis. Curabitur dapibus enim sit amet elit pharetra tincidunt feugiat nisl imperdiet. Ut convallis libero in urna ultrices accumsan. Donec sed odio eros. Donec viverra mi quis quam pulvinar at malesuada arcu rhoncus. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. In rutrum accumsan ultricies. Mauris vitae nisi at sem facilisis semper ac in est.</p>
<p>Vivamus fermentum semper porta. Nunc diam velit, adipiscing ut tristique vitae, sagittis vel odio. Maecenas convallis ullamcorper ultricies. Curabitur ornare, ligula semper consectetur sagittis, nisi diam iaculis velit, id fringilla sem nunc vel mi. Nam dictum, odio nec pretium volutpat, arcu ante placerat erat, non tristique elit urna et turpis. Quisque mi metus, ornare sit amet fermentum et, tincidunt et orci. Fusce eget orci a orci congue vestibulum. Ut dolor diam, elementum et vestibulum eu, porttitor vel elit. Curabitur venenatis pulvinar tellus gravida ornare. Sed et erat faucibus nunc euismod ultricies ut id justo. Nullam cursus suscipit nisi, et ultrices justo sodales nec. Fusce venenatis facilisis lectus ac semper. Aliquam at massa ipsum. Quisque bibendum purus convallis nulla ultrices ultricies. Nullam aliquam, mi eu aliquam tincidunt, purus velit laoreet tortor, viverra pretium nisi quam vitae mi. Fusce vel volutpat elit. Nam sagittis nisi dui.</p>
</div>
</body>
</html>

Просмотреть файл

@ -0,0 +1,16 @@
<!DOCTYPE html>
<html>
<head>
<title>Article title</title>
<meta name="description" content="This is the article description." />
</head>
<body>
<header>Site header</header>
<div>
<h1>Article title</h1>
<h2 class="author">by Jane Doe</h2>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec a diam lectus. Sed sit amet ipsum mauris. Maecenas congue ligula ac quam viverra nec consectetur ante hendrerit. Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean ut gravida lorem. Ut turpis felis, pulvinar a semper sed, adipiscing id dolor. Pellentesque auctor nisi id magna consequat sagittis. Curabitur dapibus enim sit amet elit pharetra tincidunt feugiat nisl imperdiet. Ut convallis libero in urna ultrices accumsan. Donec sed odio eros. Donec viverra mi quis quam pulvinar at malesuada arcu rhoncus. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. In rutrum accumsan ultricies. Mauris vitae nisi at sem facilisis semper ac in est.</p>
<p>Vivamus fermentum semper porta. Nunc diam velit, adipiscing ut tristique vitae, sagittis vel odio. Maecenas convallis ullamcorper ultricies. Curabitur ornare, ligula semper consectetur sagittis, nisi diam iaculis velit, id fringilla sem nunc vel mi. Nam dictum, odio nec pretium volutpat, arcu ante placerat erat, non tristique elit urna et turpis. Quisque mi metus, ornare sit amet fermentum et, tincidunt et orci. Fusce eget orci a orci congue vestibulum. Ut dolor diam, elementum et vestibulum eu, porttitor vel elit. Curabitur venenatis pulvinar tellus gravida ornare. Sed et erat faucibus nunc euismod ultricies ut id justo. Nullam cursus suscipit nisi, et ultrices justo sodales nec. Fusce venenatis facilisis lectus ac semper. Aliquam at massa ipsum. Quisque bibendum purus convallis nulla ultrices ultricies. Nullam aliquam, mi eu aliquam tincidunt, purus velit laoreet tortor, viverra pretium nisi quam vitae mi. Fusce vel volutpat elit. Nam sagittis nisi dui.</p>
</div>
</body>
</html>

Просмотреть файл

@ -0,0 +1,258 @@
<!DOCTYPE HTML>
<html>
<!--
This test reports Firefox memory use to Perfherder.
Inspired by https://areweslimyet.com/mobile
https://bugzilla.mozilla.org/show_bug.cgi?id=1233220
-->
<head>
<meta charset="utf-8">
<title>Test for Bug 1233220</title>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/MemoryStats.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://global/skin"/>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
<script type="application/javascript;version=1.8" src="head.js"></script>
<script type="application/javascript;version=1.8">
"use strict";
const { interfaces: Ci, utils: Cu, classes: Cc } = Components;
// TODO: decide on test pages. tp5?
var kUrls = [
"http://mochi.test:8888/chrome/mobile/android/tests/browser/chrome/memory_page_1.html",
"http://mochi.test:8888/chrome/mobile/android/tests/browser/chrome/memory_page_2.html",
"http://mochi.test:8888/chrome/mobile/android/tests/browser/chrome/memory_page_3.html",
"http://mochi.test:8888/chrome/mobile/android/tests/browser/chrome/memory_page_4.html"
];
var gTabsOpened = 0;
var gWindow = null;
var gLastTab = null;
var gResults = [];
Cu.import("resource://gre/modules/Services.jsm");
var BrowserApp = Services.wm.getMostRecentWindow("navigator:browser").BrowserApp;
SimpleTest.waitForExplicitFinish();
SimpleTest.requestLongerTimeout(2); // several long waits and GCs make for a long-running test
SimpleTest.requestCompleteLog(); // so that "PERFHERDER_DATA" can be scraped from the log
function checkpoint(aName) {
var mrm = Cc["@mozilla.org/memory-reporter-manager;1"].getService(Ci.nsIMemoryReporterManager);
gResults.push( { name: aName, resident: mrm.resident } );
info(`${aName} | Resident Memory: ${mrm.resident}`);
}
var browserListener = {
onOpenWindow: function(aWindow) {
var win = aWindow.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindow);
win.addEventListener("UIReady", function listener(aEvent) {
win.removeEventListener("UIReady", listener, false);
attachTo(win);
}, false);
},
onCloseWindow: function(aWindow) {
detachFrom(aWindow);
},
onWindowTitleChange: function(aWindow, aTitle) {
}
};
function doFullGc(aCallback, aIterations) {
var threadMan = Cc["@mozilla.org/thread-manager;1"].getService(Ci.nsIThreadManager);
var domWindowUtils = gWindow.QueryInterface(Components.interfaces.nsIInterfaceRequestor).getInterface(Components.interfaces.nsIDOMWindowUtils);
function runSoon(f) {
threadMan.mainThread.dispatch({ run: f }, Ci.nsIThread.DISPATCH_NORMAL);
}
function cc() {
if (domWindowUtils.cycleCollect) {
domWindowUtils.cycleCollect();
}
Services.obs.notifyObservers(null, "child-cc-request", null);
}
function minimizeInner() {
// In order of preference: schedulePreciseShrinkingGC, schedulePreciseGC
// garbageCollect
if (++j <= aIterations) {
var schedGC = Cu.schedulePreciseShrinkingGC;
if (!schedGC) {
schedGC = Cu.schedulePreciseGC;
}
Services.obs.notifyObservers(null, "child-gc-request", null);
if (schedGC) {
schedGC.call(Cu, { callback: function () {
runSoon(function () { cc(); runSoon(minimizeInner); });
} });
} else {
if (domWindowUtils.garbageCollect) {
domWindowUtils.garbageCollect();
}
runSoon(function () { cc(); runSoon(minimizeInner); });
}
} else {
runSoon(aCallback);
}
}
var j = 0;
minimizeInner();
}
function attachTo(aWindow) {
if (gWindow != null) {
info("attempting to attach to a second window [" + aWindow + "] while already attached to one window [" + gWindow + "]");
return;
}
gWindow = aWindow;
setTimeout(startTest, 0);
}
function detachFrom(aWindow) {
if (gWindow == aWindow) {
gWindow = null;
}
}
function startup() {
var enumerator = Services.wm.getEnumerator("navigator:browser");
while (enumerator.hasMoreElements()) {
// potential race condition here - the window may not be ready yet at
// this point, so ideally we would test for that. but i can't find a
// property that reflects whether or not UIReady has been fired, so
// for now just assume the window is ready
attachTo(enumerator.getNext().QueryInterface(Ci.nsIDOMWindow));
}
Services.wm.addListener(browserListener);
}
function startTest() {
checkpoint("Fresh start");
setTimeout(settle, 30000);
}
function settle() {
checkpoint("Fresh start [+30s]");
openTab();
}
function openTab() {
var urlIndex = gTabsOpened++;
if (urlIndex >= kUrls.length) {
checkpoint("After tabs");
setTimeout(postOpening, 30000);
return;
}
dump("opening tab with url [" + kUrls[urlIndex] + "]");
gLastTab = BrowserApp.addTab(kUrls[urlIndex], { selected: true });
setTimeout(waitForTab, 10000);
}
function waitForTab() {
if (gLastTab.browser.contentDocument.readyState === "complete") {
gLastTab = null;
openTab();
} else {
setTimeout(waitForTab, 10000);
}
}
function postOpening() {
checkpoint("After tabs [+30s]");
doFullGc(() => closeTabs());
}
function closeTabs() {
checkpoint("After tabs [+30s, forced GC]");
var tabCount = BrowserApp.tabs.length;
for (var i = 1; i < tabCount; i++) {
BrowserApp.closeTab(BrowserApp.tabs[i]);
}
var closeListener = {
observe: function(aSubject, aTopic, aData) {
tabCount--;
dump("tab count dropped to [" + tabCount + "]");
if (tabCount == 1) {
Services.obs.removeObserver(this, "Tab:Closed", false);
setTimeout(tabsClosed, 0);
}
}
};
Services.obs.addObserver(closeListener, "Tab:Closed", false);
}
function tabsClosed() {
checkpoint("Tabs closed");
setTimeout(postClosing, 30000);
}
function postClosing() {
checkpoint("Tabs closed [+30s]");
doFullGc(() => {
checkpoint("Tabs closed [+30s, forced GC]");
finalReport();
ok(true, "memory logging complete -- view results in Perfherder");
SimpleTest.finish();
});
}
function geomean(aProperty) {
// https://en.wikipedia.org/wiki/Geometric_mean#Relationship_with_arithmetic_mean_of_logarithms
var logsum = 0;
var i;
for (i = 0; i < gResults.length; i++) {
var result = gResults[i];
logsum += Math.log(result[aProperty]);
}
return Math.round(Math.exp(logsum/gResults.length));
}
function finalReport() {
var i;
var perfherder = "PERFHERDER_DATA: ";
perfherder += "{\"framework\": {\"name\": \"awsy\"}, ";
perfherder += "\"suites\": [";
perfherder += "{\"name\": \"Resident Memory\", ";
perfherder += "\"subtests\": [";
for (i = 0; i < gResults.length; i++) {
var result = gResults[i];
if (i > 0) {
perfherder += ", ";
}
perfherder += `{\"name\": \"${result.name}\", \"value\": ${result.resident}}`;
}
perfherder += "], "; // end subtests
perfherder += "\"value\": "+geomean("resident");
perfherder += "}"; // end Resident Memory suite
perfherder += "]"; // end suites
perfherder += "}"; // end PERFHERDER_DATA
info(perfherder);
}
startup();
</script>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1233220">Mozilla Bug 1233220</a>
<br>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
</pre>
</body>
</html>