Bug 267645 part 1. Add a way to ask for DOMException to be exposed in sandboxes. r=bholley
authorBoris Zbarsky <bzbarsky@mit.edu>
Sat, 22 Feb 2020 04:56:52 +0000
changeset 515099 942a92874526e7a18167af89e358d69cbaeab268
parent 515098 d21671811dffc6de7c7a0a7ceb22701fcfc506f7
child 515100 039e8fd2928d8d368ad892fb065bb2471e13d86e
push id37149
push userdvarga@mozilla.com
push dateSat, 22 Feb 2020 09:52:08 +0000
treeherdermozilla-central@bd65ac107627 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbholley
bugs267645
milestone75.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 267645 part 1. Add a way to ask for DOMException to be exposed in sandboxes. r=bholley Differential Revision: https://phabricator.services.mozilla.com/D63278
js/xpconnect/src/Sandbox.cpp
js/xpconnect/src/xpcprivate.h
js/xpconnect/tests/unit/test_sandbox_DOMException.js
js/xpconnect/tests/unit/xpcshell.ini
--- a/js/xpconnect/src/Sandbox.cpp
+++ b/js/xpconnect/src/Sandbox.cpp
@@ -33,16 +33,17 @@
 #include "Crypto.h"
 #include "mozilla/dom/BindingUtils.h"
 #include "mozilla/dom/BlobBinding.h"
 #include "mozilla/dom/cache/CacheStorage.h"
 #include "mozilla/dom/CSSBinding.h"
 #include "mozilla/dom/CSSRuleBinding.h"
 #include "mozilla/dom/DirectoryBinding.h"
 #include "mozilla/dom/DocumentBinding.h"
+#include "mozilla/dom/DOMExceptionBinding.h"
 #include "mozilla/dom/DOMParserBinding.h"
 #include "mozilla/dom/DOMTokenListBinding.h"
 #include "mozilla/dom/ElementBinding.h"
 #include "mozilla/dom/EventBinding.h"
 #include "mozilla/dom/IndexedDatabaseManager.h"
 #include "mozilla/dom/Fetch.h"
 #include "mozilla/dom/FileBinding.h"
 #include "mozilla/dom/HeadersBinding.h"
@@ -838,16 +839,18 @@ bool xpc::GlobalProperties::Parse(JSCont
     } else if (JS_LinearStringEqualsLiteral(nameStr, "CSS")) {
       CSS = true;
     } else if (JS_LinearStringEqualsLiteral(nameStr, "CSSRule")) {
       CSSRule = true;
     } else if (JS_LinearStringEqualsLiteral(nameStr, "Document")) {
       Document = true;
     } else if (JS_LinearStringEqualsLiteral(nameStr, "Directory")) {
       Directory = true;
+    } else if (JS_LinearStringEqualsLiteral(nameStr, "DOMException")) {
+      DOMException = true;
     } else if (JS_LinearStringEqualsLiteral(nameStr, "DOMParser")) {
       DOMParser = true;
     } else if (JS_LinearStringEqualsLiteral(nameStr, "DOMTokenList")) {
       DOMTokenList = true;
     } else if (JS_LinearStringEqualsLiteral(nameStr, "Element")) {
       Element = true;
     } else if (JS_LinearStringEqualsLiteral(nameStr, "Event")) {
       Event = true;
@@ -942,18 +945,23 @@ bool xpc::GlobalProperties::Define(JSCon
 
   if (Directory && !dom::Directory_Binding::GetConstructorObject(cx))
     return false;
 
   if (Document && !dom::Document_Binding::GetConstructorObject(cx)) {
     return false;
   }
 
-  if (DOMParser && !dom::DOMParser_Binding::GetConstructorObject(cx))
+  if (DOMException && !dom::DOMException_Binding::GetConstructorObject(cx)) {
     return false;
+  }
+
+  if (DOMParser && !dom::DOMParser_Binding::GetConstructorObject(cx)) {
+    return false;
+  }
 
   if (DOMTokenList && !dom::DOMTokenList_Binding::GetConstructorObject(cx)) {
     return false;
   }
 
   if (Element && !dom::Element_Binding::GetConstructorObject(cx)) return false;
 
   if (Event && !dom::Event_Binding::GetConstructorObject(cx)) return false;
--- a/js/xpconnect/src/xpcprivate.h
+++ b/js/xpconnect/src/xpcprivate.h
@@ -2232,16 +2232,17 @@ struct GlobalProperties {
 
   // Interface objects we can expose.
   bool Blob : 1;
   bool ChromeUtils : 1;
   bool CSS : 1;
   bool CSSRule : 1;
   bool Directory : 1;
   bool Document : 1;
+  bool DOMException : 1;
   bool DOMParser : 1;
   bool DOMTokenList : 1;
   bool Element : 1;
   bool Event : 1;
   bool File : 1;
   bool FileReader : 1;
   bool FormData : 1;
   bool Headers : 1;
new file mode 100644
--- /dev/null
+++ b/js/xpconnect/tests/unit/test_sandbox_DOMException.js
@@ -0,0 +1,10 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+function run_test() {
+  var Cu = Components.utils;
+  var sb = new Cu.Sandbox('http://www.example.com',
+                          { wantGlobalProperties: ["DOMException"] });
+  sb.notEqual = Assert.notEqual.bind(Assert);
+  Cu.evalInSandbox('notEqual(DOMException, undefined);', sb);
+}
--- a/js/xpconnect/tests/unit/xpcshell.ini
+++ b/js/xpconnect/tests/unit/xpcshell.ini
@@ -103,16 +103,17 @@ head = head_ongc.js
 [test_allowedDomains.js]
 [test_allowedDomainsXHR.js]
 [test_nuke_sandbox.js]
 [test_nuke_sandbox_event_listeners.js]
 [test_nuke_webextension_wrappers.js]
 [test_subScriptLoader.js]
 [test_rewrap_dead_wrapper.js]
 [test_sandbox_metadata.js]
+[test_sandbox_DOMException.js]
 [test_exportFunction.js]
 [test_promise.js]
 [test_returncode.js]
 [test_textDecoder.js]
 [test_url.js]
 [test_URLSearchParams.js]
 [test_fileReader.js]
 [test_messageChannel.js]