1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */ 3 /* This Source Code Form is subject to the terms of the Mozilla Public 4 * License, v. 2.0. If a copy of the MPL was not distributed with this file, 5 * You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 7 /* 8 * Constant flags that describe how a document is sandboxed according to the 9 * HTML5 spec. 10 */ 11 12 #ifndef nsSandboxFlags_h___ 13 #define nsSandboxFlags_h___ 14 15 /** 16 * This constant denotes the lack of a sandbox attribute/directive. 17 */ 18 const unsigned long SANDBOXED_NONE = 0x0; 19 20 /** 21 * This flag prevents content from navigating browsing contexts other than 22 * itself, browsing contexts nested inside it, the top-level browsing context 23 * and browsing contexts that it has opened. 24 * As it is always on for sandboxed browsing contexts, it is used implicitly 25 * within the code by checking that the overall flags are non-zero. 26 * It is only uesd directly when the sandbox flags are initially set up. 27 */ 28 const unsigned long SANDBOXED_NAVIGATION = 0x1; 29 30 /** 31 * This flag prevents content from creating new auxiliary browsing contexts, 32 * e.g. using the target attribute, or the window.open() method. 33 */ 34 const unsigned long SANDBOXED_AUXILIARY_NAVIGATION = 0x2; 35 36 /** 37 * This flag prevents content from navigating their top-level browsing 38 * context. 39 */ 40 const unsigned long SANDBOXED_TOPLEVEL_NAVIGATION = 0x4; 41 42 /** 43 * This flag prevents content from instantiating plugins, whether using the 44 * embed element, the object element, or through navigation of a nested browsing 45 * context, unless those plugins can be secured. 46 */ 47 const unsigned long SANDBOXED_PLUGINS = 0x8; 48 49 /** 50 * This flag forces content into a unique origin, thus preventing it from 51 * accessing other content from the same origin. 52 * This flag also prevents script from reading from or writing to the 53 * document.cookie IDL attribute, and blocks access to localStorage. 54 */ 55 const unsigned long SANDBOXED_ORIGIN = 0x10; 56 57 /** 58 * This flag blocks form submission. 59 */ 60 const unsigned long SANDBOXED_FORMS = 0x20; 61 62 /** 63 * This flag blocks the document from acquiring pointerlock. 64 */ 65 const unsigned long SANDBOXED_POINTER_LOCK = 0x40; 66 67 /** 68 * This flag blocks script execution. 69 */ 70 const unsigned long SANDBOXED_SCRIPTS = 0x80; 71 72 /** 73 * This flag blocks features that trigger automatically, such as 74 * automatically playing a video or automatically focusing a form control. 75 */ 76 const unsigned long SANDBOXED_AUTOMATIC_FEATURES = 0x100; 77 78 /** 79 * This flag prevents URL schemes that use storage areas from being able to 80 * access the origin's data. 81 */ 82 // We don't have an explicit representation of this one, apparently? 83 // const unsigned long SANDBOXED_STORAGE_AREA_URLS = 0x200; 84 85 /** 86 * This flag blocks the document from changing document.domain. 87 */ 88 const unsigned long SANDBOXED_DOMAIN = 0x400; 89 90 /** 91 * This flag prevents content from using window.alert(), window.confirm(), 92 * window.print(), window.prompt() and the beforeunload event from putting up 93 * dialogs. 94 */ 95 const unsigned long SANDBOXED_MODALS = 0x800; 96 97 /** 98 * This flag prevents content from escaping the sandbox by ensuring that any 99 * auxiliary browsing context it creates inherits the content's active 100 * sandboxing flag set. 101 */ 102 const unsigned long SANDBOX_PROPAGATES_TO_AUXILIARY_BROWSING_CONTEXTS = 0x1000; 103 104 /** 105 * This flag prevents locking screen orientation. 106 */ 107 const unsigned long SANDBOXED_ORIENTATION_LOCK = 0x2000; 108 109 /** 110 * This flag disables the Presentation API. 111 */ 112 const unsigned long SANDBOXED_PRESENTATION = 0x4000; 113 114 /** 115 * This flag disables access to the first-party storage area by user activation. 116 */ 117 const unsigned long SANDBOXED_STORAGE_ACCESS = 0x8000; 118 119 /** 120 * This flag prevents content from navigating their top-level browsing 121 * context only when the user hasn't interacted with the browser. 122 */ 123 const unsigned long SANDBOXED_TOPLEVEL_NAVIGATION_USER_ACTIVATION = 0x20000; 124 125 /** 126 * This flag disables content from initiating or instantiating downloads, 127 * whether through downloading hyperlinks or through navigation that gets 128 * handled as a download. 129 */ 130 const unsigned long SANDBOXED_ALLOW_DOWNLOADS = 0x10000; 131 132 const unsigned long SANDBOX_ALL_FLAGS = 0xFFFFF; 133 #endif 134