1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
6 * TestFixture for SUID Sandbox testing.
7 * @extends {testing.Test}
10 function SandboxStatusUITest() {}
12 SandboxStatusUITest.prototype = {
13 __proto__: testing.Test.prototype,
15 * Browse to the options page & call our preLoad().
17 browsePreload: 'chrome://sandbox',
21 // This test is for Linux only.
23 // - If failures of this test are a problem on a bot under your care,
24 // the proper way to address such failures is to install the SUID
26 // http://code.google.com/p/chromium/wiki/LinuxSUIDSandboxDevelopment
27 // - PLEASE DO NOT GLOBALLY DISABLE THIS TEST.
28 // SUID sandbox is currently incompatible with AddressSanitizer,
29 // see http://crbug.com/137653.
30 GEN('#if defined(OS_LINUX) && !defined(ADDRESS_SANITIZER)');
31 GEN('# define MAYBE_testSUIDSandboxEnabled \\');
32 GEN(' testSUIDSandboxEnabled');
34 GEN('# define MAYBE_testSUIDSandboxEnabled \\');
35 GEN(' DISABLED_testSUIDSandboxEnabled');
39 * Test if the SUID sandbox is enabled.
41 TEST_F('SandboxStatusUITest', 'MAYBE_testSUIDSandboxEnabled', function() {
42 var suidyesstring = 'SUID Sandbox\tYes';
43 var suidnostring = 'SUID Sandbox\tNo';
44 var suidyes = document.body.innerText.match(suidyesstring);
45 var suidno = document.body.innerText.match(suidnostring);
47 expectEquals(null, suidno);
48 assertFalse(suidyes === null);
49 expectEquals(suidyesstring, suidyes[0]);
52 // The seccomp-bpf sandbox is also not compatible with ASAN.
53 GEN('#if !defined(OS_LINUX) || defined(ADDRESS_SANITIZER)');
54 GEN('# define MAYBE_testBPFSandboxEnabled \\');
55 GEN(' DISABLED_testBPFSandboxEnabled');
56 GEN('#elif !defined(OS_CHROMEOS) && defined(ARCH_CPU_ARM_FAMILY)');
57 // Not yet available on the ARM linux bots: http://crbug.com/243478
58 GEN('# define MAYBE_testBPFSandboxEnabled \\');
59 GEN(' DISABLED_testBPFSandboxEnabled');
61 GEN('# define MAYBE_testBPFSandboxEnabled \\');
62 GEN(' testBPFSandboxEnabled');
66 * Test if the seccomp-bpf sandbox is enabled.
68 TEST_F('SandboxStatusUITest', 'MAYBE_testBPFSandboxEnabled', function() {
69 var bpfyesstring = 'Seccomp-BPF sandbox\tYes';
70 var bpfnostring = 'Seccomp-BPF sandbox\tNo';
71 var bpfyes = document.body.innerText.match(bpfyesstring);
72 var bpfno = document.body.innerText.match(bpfnostring);
74 expectEquals(null, bpfno);
75 assertFalse(bpfyes === null);
76 expectEquals(bpfyesstring, bpfyes[0]);
80 * TestFixture for GPU Sandbox testing.
81 * @extends {testing.Test}
84 function GPUSandboxStatusUITest() {}
86 GPUSandboxStatusUITest.prototype = {
87 __proto__: testing.Test.prototype,
89 * Browse to the options page & call our preLoad().
91 browsePreload: 'chrome://gpu',
95 // This test is disabled because it can only pass on real hardware. We
96 // arrange for it to run on real hardware in specific configurations
97 // (such as Chrome OS hardware, via Autotest), then run it with
98 // --gtest_also_run_disabled_tests on those configurations.
101 * Test if the GPU sandbox is enabled.
103 TEST_F('GPUSandboxStatusUITest', 'DISABLED_testGPUSandboxEnabled', function() {
104 var gpuyesstring = 'Sandboxed\ttrue';
105 var gpunostring = 'Sandboxed\tfalse';
107 var observer = new MutationObserver(function(mutations) {
108 mutations.forEach(function(mutation) {
109 for (var i = 0; i < mutation.addedNodes.length; i++) {
110 // Here we can inspect each of the added nodes. We expect
111 // to find one that contains one of the GPU status strings.
112 var addedNode = mutation.addedNodes[i];
113 // Check for both. If it contains neither, it's an unrelated
114 // mutation event we don't care about. But if it contains one,
115 // pass or fail accordingly.
116 var gpuyes = addedNode.innerText.match(gpuyesstring);
117 var gpuno = addedNode.innerText.match(gpunostring);
118 if (gpuyes || gpuno) {
119 expectEquals(null, gpuno);
120 expectTrue(gpuyes && (gpuyes[0] == gpuyesstring));
126 observer.observe(document.getElementById('basic-info'), {childList: true});