Bug 1218364 - windowless browser windows should not crash on Troubleshoot. r=billm,jrmuizel

This commit is contained in:
Luca Greco 2015-11-11 07:08:00 +01:00
parent a0b96e029d
commit b6dcf4514a
5 changed files with 54 additions and 1 deletions

View File

@ -760,6 +760,7 @@ void
ClientLayerManager::GetBackendName(nsAString& aName)
{
switch (mForwarder->GetCompositorBackendType()) {
case LayersBackend::LAYERS_NONE: aName.AssignLiteral("None"); return;
case LayersBackend::LAYERS_BASIC: aName.AssignLiteral("Basic"); return;
case LayersBackend::LAYERS_OPENGL: aName.AssignLiteral("OpenGL"); return;
case LayersBackend::LAYERS_D3D9: aName.AssignLiteral("Direct3D 9"); return;

View File

@ -0,0 +1,4 @@
[DEFAULT]
support-files =
[browser_windowless_troubleshoot_crash.js]

View File

@ -0,0 +1,43 @@
let { Services } = Cu.import("resource://gre/modules/Services.jsm", {});
add_task(function* test_windowlessBrowserTroubleshootCrash() {
let webNav = Services.appShell.createWindowlessBrowser(false);
let onLoaded = new Promise((resolve, reject) => {
let docShell = webNav.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDocShell);
let listener = {
observe(contentWindow, topic, data) {
let observedDocShell = contentWindow.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIWebNavigation)
.QueryInterface(Ci.nsIDocShellTreeItem)
.sameTypeRootTreeItem
.QueryInterface(Ci.nsIDocShell);
if (docShell === observedDocShell) {
Services.obs.removeObserver(listener, "content-document-global-created", false);
resolve();
}
}
}
Services.obs.addObserver(listener, "content-document-global-created", false);
});
webNav.loadURI("about:blank", 0, null, null, null);
yield onLoaded;
let winUtils = webNav.document.defaultView.
QueryInterface(Ci.nsIInterfaceRequestor).
getInterface(Ci.nsIDOMWindowUtils);
is(winUtils.layerManagerType, "None", "windowless browser's layerManagerType should be 'None'");
ok(true, "not crashed");
var Troubleshoot = Cu.import("resource://gre/modules/Troubleshoot.jsm", {}).Troubleshoot;
var data = yield new Promise((resolve, reject) => {
Troubleshoot.snapshot((data) => {
resolve(data);
});
});
ok(data.graphics.windowLayerManagerType !== "None", "windowless browser window should not set windowLayerManagerType to 'None'");
});

View File

@ -6,3 +6,4 @@
XPCSHELL_TESTS_MANIFESTS += ['unit/xpcshell.ini']
MOCHITEST_MANIFESTS += ['mochitest/mochitest.ini']
BROWSER_CHROME_MANIFESTS += ['browser/browser.ini']

View File

@ -307,11 +307,15 @@ var dataProviders = {
data.numAcceleratedWindows = 0;
let winEnumer = Services.ww.getWindowEnumerator();
while (winEnumer.hasMoreElements()) {
data.numTotalWindows++;
let winUtils = winEnumer.getNext().
QueryInterface(Ci.nsIInterfaceRequestor).
getInterface(Ci.nsIDOMWindowUtils);
try {
// NOTE: windowless browser's windows should not be reported in the graphics troubleshoot report
if (winUtils.layerManagerType == "None") {
continue;
}
data.numTotalWindows++;
data.windowLayerManagerType = winUtils.layerManagerType;
data.windowLayerManagerRemote = winUtils.layerManagerRemote;
data.supportsHardwareH264 = winUtils.supportsHardwareH264Decoding;