Skip to content

Commit

Permalink
Adds browsertest for chrome://sandbox on Windows.
Browse files Browse the repository at this point in the history
Bug: 997273
Change-Id: I998893ad03b3cf4e32e56f7c771033a0113ace17
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1885452
Commit-Queue: Alex Gough <ajgo@chromium.org>
Reviewed-by: Matthew Denton <mpdenton@chromium.org>
Cr-Commit-Position: refs/heads/master@{#712005}
  • Loading branch information
quidity authored and Commit Bot committed Nov 2, 2019
1 parent 362a38e commit a561e74
Showing 1 changed file with 51 additions and 6 deletions.
57 changes: 51 additions & 6 deletions chrome/test/data/webui/sandboxstatus_browsertest.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,20 +98,20 @@ GPUSandboxStatusUITest.prototype = {
* Test if the GPU sandbox is enabled.
*/
TEST_F('GPUSandboxStatusUITest', 'DISABLED_testGPUSandboxEnabled', function() {
var gpuyesstring = 'Sandboxed\ttrue';
var gpunostring = 'Sandboxed\tfalse';
const gpuyesstring = 'Sandboxed\ttrue';
const gpunostring = 'Sandboxed\tfalse';

var observer = new MutationObserver(function(mutations) {
let observer = new MutationObserver(function(mutations) {
mutations.forEach(function(mutation) {
for (var i = 0; i < mutation.addedNodes.length; i++) {
// Here we can inspect each of the added nodes. We expect
// to find one that contains one of the GPU status strings.
var addedNode = mutation.addedNodes[i];
let addedNode = mutation.addedNodes[i];
// Check for both. If it contains neither, it's an unrelated
// mutation event we don't care about. But if it contains one,
// pass or fail accordingly.
var gpuyes = addedNode.innerText.match(gpuyesstring);
var gpuno = addedNode.innerText.match(gpunostring);
let gpuyes = addedNode.innerText.match(gpuyesstring);
let gpuno = addedNode.innerText.match(gpunostring);
if (gpuyes || gpuno) {
expectEquals(null, gpuno);
expectTrue(gpuyes && (gpuyes[0] == gpuyesstring));
Expand All @@ -122,3 +122,48 @@ TEST_F('GPUSandboxStatusUITest', 'DISABLED_testGPUSandboxEnabled', function() {
});
observer.observe(document.getElementById('basic-info'), {childList: true});
});

/**
* TestFixture for chrome://sandbox on Windows.
* @extends {testing.Test}
* @constructor
*/
function SandboxStatusWindowsUITest() {}

SandboxStatusWindowsUITest.prototype = {
__proto__: testing.Test.prototype,
/**
* Browse to the options page & call our preLoad().
*/
browsePreload: 'chrome://sandbox',
isAsync: true
};

// This test is for Windows only.
GEN('#if defined(OS_WIN)');
GEN('# define MAYBE_testSandboxStatus \\');
GEN(' testSandboxStatus');
GEN('#else');
GEN('# define MAYBE_testSandboxStatus \\');
GEN(' DISABLED_testSandboxStatus');
GEN('#endif');

/**
* Test that chrome://sandbox functions on Windows.
*/
TEST_F('SandboxStatusWindowsUITest', 'MAYBE_testSandboxStatus', function() {
var sandboxTitle = 'Sandbox Status';
var sandboxPolicies = 'policies:';
var sandboxMitigations = 'platformMitigations';

var titleyes = document.body.innerText.match(sandboxTitle);
expectTrue(titleyes !== null);

var rawNode = document.getElementById('raw-info');
var policiesyes = rawNode.innerText.match(sandboxPolicies);
expectTrue(policiesyes !== null);
var mitigationsyes = rawNode.innerText.match(sandboxMitigations);
expectTrue(mitigationsyes !== null);

testDone();
});

0 comments on commit a561e74

Please sign in to comment.