Bug 1192989 - Simplify handling by ifdefing in all.js. - r=kamidphish

This commit is contained in:
Jeff Gilbert 2015-08-10 14:57:15 -07:00
parent 527bf87e31
commit 49187c869d
5 changed files with 44 additions and 39 deletions

View File

@ -161,18 +161,8 @@ WebGLContext::IsExtensionSupported(WebGLExtensionID ext) const
gl->IsExtensionSupported(gl::GLContext::ANGLE_texture_compression_dxt5);
case WebGLExtensionID::WEBGL_debug_renderer_info:
{
bool isEnabled = true;
return Preferences::GetBool("webgl.enable-debug-renderer-info", false);
#ifdef RELEASE_BUILD
// Keep this disabled on Release and Beta for now. (see bug 1171228)
isEnabled = false;
#endif
if (Preferences::GetBool("webgl.disable-debug-renderer-info", false))
isEnabled = false;
return isEnabled;
}
case WebGLExtensionID::WEBGL_depth_texture:
// WEBGL_depth_texture supports DEPTH_STENCIL textures
if (!gl->IsSupported(gl::GLFeature::packed_depth_stencil))

View File

@ -2,11 +2,6 @@
<html>
<script>
var Cu = parent.Components.utils;
Cu.import("resource://gre/modules/AppConstants.jsm");
// This gives us `AppConstants` in the global scope.
// We need this because we only expose debug_renderer_info #ifndef MOZ_RELEASE_BUILD.
// This should match AppConstants.RELEASE_BUILD.
// This file has the portion of the test_webgl_renderer_info chrome mochitest
// that has to run as non-chrome to check that this WebGL extension is not exposed to content
@ -23,21 +18,18 @@ function ok(res, msg) {
function messageListener(e) {
// This is how the chrome test tells us to start running -- we have to wait for this
// message to avoid running before it's set up its event handler.
if (e.data == "run") {
run();
if (e.data.run) {
var canBeUnprivileged = e.data.canBeUnprivileged;
run(canBeUnprivileged);
}
}
window.addEventListener("message", messageListener, true);
function run() {
function run(canBeUnprivileged) {
const UNMASKED_VENDOR_WEBGL = 0x9245;
const UNMASKED_RENDERER_WEBGL = 0x9246;
var shouldHaveRendererInfo = false;
if (!AppConstants.RELEASE_BUILD)
shouldHaveRendererInfo = true;
var canvas = document.createElement("canvas");
var gl = canvas.getContext("experimental-webgl");
@ -51,7 +43,7 @@ function run() {
+ " WEBGL_debug_renderer_info extension");
var exts = gl.getSupportedExtensions();
if (shouldHaveRendererInfo) {
if (canBeUnprivileged) {
ok(exts.indexOf("WEBGL_debug_renderer_info") != -1,
"WEBGL_debug_renderer_info should be listed by getSupportedExtensions in"
+ " non-chrome contexts on non-RELEASE_BUILDs");

View File

@ -17,6 +17,16 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=666446
const UNMASKED_VENDOR_WEBGL = 0x9245;
const UNMASKED_RENDERER_WEBGL = 0x9246;
var Cu = parent.Components.utils;
Cu.import("resource://gre/modules/AppConstants.jsm");
// This gives us `AppConstants` in the global scope.
// We need this because we only expose debug_renderer_info #ifndef MOZ_RELEASE_BUILD.
// This should match AppConstants.RELEASE_BUILD.
const canBeUnprivileged = !AppConstants.RELEASE_BUILD;
function isNonEmptyString(s)
{
return s && (typeof s) == "string";
@ -67,7 +77,7 @@ function main()
// Now run the non-chrome code to verify the security of this WebGL chrome-only extension.
var iframe = document.createElement("iframe");
iframe.src = "chrome://mochitests/content/chrome/dom/canvas/test/chrome/nonchrome_webgl_debug_renderer_info.html";
iframe.src = "http://mochi.test:8888/chrome/dom/canvas/test/chrome/nonchrome_webgl_debug_renderer_info.html";
iframe.onload = function () {
@ -77,7 +87,9 @@ function main()
checkChromeCase(iframe.contentDocument.createElement("canvas"));
iframe.contentWindow.addEventListener("message", messageListener, false);
iframe.contentWindow.postMessage("run", "*");
iframe.contentWindow.postMessage({run: true,
canBeUnprivileged: canBeUnprivileged},
"*");
};
document.body.appendChild(iframe);

View File

@ -12,7 +12,7 @@ function AssertError(gl, expected, info) {
while (gl.getError()) {}
ok(actual == expected,
'For ' + info + ', expected 0x' + expected.toString(16) + ', got 0x'
'For ' + info + ', expected GL error 0x' + expected.toString(16) + ', got 0x'
+ actual.toString(16));
}
@ -23,17 +23,20 @@ var VENDOR_OVERRIDE = 'overridden vendor';
function TestExt() {
var ext = gl.getExtension('WEBGL_debug_renderer_info');
ok(ext, 'Should have access to \'WEBGL_debug_renderer_info\'.');
ok(ext, 'When pref enabled: Should have access to \'WEBGL_debug_renderer_info\'.');
AssertError(gl, 0, 'start of test');
var renderer = gl.getParameter(ext.UNMASKED_RENDERER_WEBGL);
AssertError(gl, 0, 'UNMASKED_RENDERER_WEBGL');
ok(renderer,
'UNMASKED_RENDERER_WEBGL value should not be empty, was \'' + renderer + '\'');
'When pref enabled: UNMASKED_RENDERER_WEBGL value should not be empty, was \''
+ renderer + '\'');
var vendor = gl.getParameter(ext.UNMASKED_VENDOR_WEBGL);
AssertError(gl, 0, 'UNMASKED_VENDOR_WEBGL');
ok(vendor, 'UNMASKED_VENDOR_WEBGL value should not be empty, was \'' + vendor + '\'');
ok(vendor,
'When pref enabled: UNMASKED_VENDOR_WEBGL value should not be empty, was \''
+ vendor + '\'');
var prefArrArr = [
['webgl.renderer-string-override', RENDERER_OVERRIDE],
@ -45,23 +48,23 @@ function TestExt() {
function TestOverrides() {
var ext = gl.getExtension('WEBGL_debug_renderer_info');
ok(ext, 'Should have access to \'WEBGL_debug_renderer_info\'.');
ok(ext, 'When overrides set: Should have access to \'WEBGL_debug_renderer_info\'.');
AssertError(gl, 0, 'start of test');
var renderer = gl.getParameter(ext.UNMASKED_RENDERER_WEBGL);
AssertError(gl, 0, 'UNMASKED_RENDERER_WEBGL');
ok(renderer == RENDERER_OVERRIDE,
'UNMASKED_RENDERER_WEBGL value should be \'' + RENDERER_OVERRIDE + '\', was \''
+ renderer + '\'');
'When overrides set: UNMASKED_RENDERER_WEBGL value should be \'' + RENDERER_OVERRIDE
+ '\', was \'' + renderer + '\'');
var vendor = gl.getParameter(ext.UNMASKED_VENDOR_WEBGL);
AssertError(gl, 0, 'UNMASKED_VENDOR_WEBGL');
ok(vendor == VENDOR_OVERRIDE,
'UNMASKED_VENDOR_WEBGL value should be \'' + VENDOR_OVERRIDE + '\', was \'' + vendor
+ '\'');
'When overrides set: UNMASKED_VENDOR_WEBGL value should be \'' + VENDOR_OVERRIDE
+ '\', was \'' + vendor + '\'');
var prefArrArr = [
['webgl.disable-debug-renderer-info', true],
['webgl.enable-debug-renderer-info', false],
];
var prefEnv = {'set': prefArrArr};
SpecialPowers.pushPrefEnv(prefEnv, TestDisable);
@ -69,7 +72,8 @@ function TestOverrides() {
function TestDisable() {
var ext = gl.getExtension('WEBGL_debug_renderer_info');
ok(!ext, 'Should not have access to \'WEBGL_debug_renderer_info\'.');
ok(!ext,
'When pref disabled: Should not have access to \'WEBGL_debug_renderer_info\'.');
ok(true, 'Test complete.');
SimpleTest.finish();
@ -87,7 +91,7 @@ function TestDisable() {
SimpleTest.waitForExplicitFinish();
var prefArrArr = [
['webgl.disable-debug-renderer-info', false],
['webgl.enable-debug-renderer-info', true],
];
var prefEnv = {'set': prefArrArr};
SpecialPowers.pushPrefEnv(prefEnv, TestExt);

View File

@ -4152,7 +4152,14 @@ pref("webgl.enable-privileged-extensions", false);
pref("webgl.bypass-shader-validation", false);
pref("webgl.enable-prototype-webgl2", false);
pref("webgl.disable-fail-if-major-performance-caveat", false);
pref("webgl.disable-debug-renderer-info", false);
#ifdef RELEASE_BUILD
// Keep this disabled on Release and Beta for now. (see bug 1171228)
pref("webgl.enable-debug-renderer-info", false);
#else
pref("webgl.enable-debug-renderer-info", true);
#endif
pref("webgl.renderer-string-override", "");
pref("webgl.vendor-string-override", "");