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');
57 GEN('# define MAYBE_testBPFSandboxEnabled \\');
58 GEN(' testBPFSandboxEnabled');
62 * Test if the seccomp-bpf sandbox is enabled.
64 TEST_F('SandboxStatusUITest', 'MAYBE_testBPFSandboxEnabled', function() {
65 var bpfyesstring
= 'Seccomp-BPF sandbox\tYes';
66 var bpfnostring
= 'Seccomp-BPF sandbox\tNo';
67 var bpfyes
= document
.body
.innerText
.match(bpfyesstring
);
68 var bpfno
= document
.body
.innerText
.match(bpfnostring
);
70 expectEquals(null, bpfno
);
71 assertFalse(bpfyes
=== null);
72 expectEquals(bpfyesstring
, bpfyes
[0]);
76 * TestFixture for GPU Sandbox testing.
77 * @extends {testing.Test}
80 function GPUSandboxStatusUITest() {}
82 GPUSandboxStatusUITest
.prototype = {
83 __proto__
: testing
.Test
.prototype,
85 * Browse to the options page & call our preLoad().
87 browsePreload
: 'chrome://gpu',
91 // This test is disabled because it can only pass on real hardware. We
92 // arrange for it to run on real hardware in specific configurations
93 // (such as Chrome OS hardware, via Autotest), then run it with
94 // --gtest_also_run_disabled_tests on those configurations.
97 * Test if the GPU sandbox is enabled.
99 TEST_F('GPUSandboxStatusUITest', 'DISABLED_testGPUSandboxEnabled', function() {
100 var gpuyesstring
= 'Sandboxed\ttrue';
101 var gpunostring
= 'Sandboxed\tfalse';
103 var observer
= new MutationObserver(function(mutations
) {
104 mutations
.forEach(function(mutation
) {
105 for (var i
= 0; i
< mutation
.addedNodes
.length
; i
++) {
106 // Here we can inspect each of the added nodes. We expect
107 // to find one that contains one of the GPU status strings.
108 var addedNode
= mutation
.addedNodes
[i
];
109 // Check for both. If it contains neither, it's an unrelated
110 // mutation event we don't care about. But if it contains one,
111 // pass or fail accordingly.
112 var gpuyes
= addedNode
.innerText
.match(gpuyesstring
);
113 var gpuno
= addedNode
.innerText
.match(gpunostring
);
114 if (gpuyes
|| gpuno
) {
115 expectEquals(null, gpuno
);
116 expectTrue(gpuyes
&& (gpuyes
[0] == gpuyesstring
));
122 observer
.observe(document
.getElementById('basic-info'), {childList
: true});