[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [tor-browser] 31/37: Bug 1771084 part 3 - Freeze builtins for the shared system global. r=mccr8, peterv a=RyanVM



This is an automated email from the git hooks/post-receive script.

richard pushed a commit to branch tor-browser-91.11.0esr-11.5-1
in repository tor-browser.

commit 01a7a82f9d039fc2fa306fc49ae7f2268b219fe4
Author: Nika Layzell <nika@xxxxxxxxxxxxxxx>
AuthorDate: Tue Jun 7 19:44:59 2022 +0000

    Bug 1771084 part 3 - Freeze builtins for the shared system global. r=mccr8,peterv a=RyanVM
    
    Differential Revision: https://phabricator.services.mozilla.com/D147305
---
 js/xpconnect/loader/mozJSComponentLoader.cpp       |  4 +++-
 js/xpconnect/tests/browser/browser.ini             |  1 +
 .../tests/browser/browser_freeze_builtins.js       | 27 ++++++++++++++++++++++
 3 files changed, 31 insertions(+), 1 deletion(-)

diff --git a/js/xpconnect/loader/mozJSComponentLoader.cpp b/js/xpconnect/loader/mozJSComponentLoader.cpp
index 5e25c240d8a32..3cf91ec40b004 100644
--- a/js/xpconnect/loader/mozJSComponentLoader.cpp
+++ b/js/xpconnect/loader/mozJSComponentLoader.cpp
@@ -568,7 +568,9 @@ void mozJSComponentLoader::CreateLoaderGlobal(JSContext* aCx,
   auto backstagePass = MakeRefPtr<BackstagePass>();
   RealmOptions options;
 
-  options.creationOptions().setNewCompartmentInSystemZone();
+  options.creationOptions()
+      .setFreezeBuiltins(true)
+      .setNewCompartmentInSystemZone();
   xpc::SetPrefableRealmOptions(options);
 
   // Defer firing OnNewGlobalObject until after the __URI__ property has
diff --git a/js/xpconnect/tests/browser/browser.ini b/js/xpconnect/tests/browser/browser.ini
index aff3caba9ffd9..15d51902773a0 100644
--- a/js/xpconnect/tests/browser/browser.ini
+++ b/js/xpconnect/tests/browser/browser.ini
@@ -8,5 +8,6 @@ support-files =
   browser_realm_key_promise_frame.html
 [browser_dead_object.js]
 [browser_exception_leak.js]
+[browser_freeze_builtins.js]
 [browser_parent_process_hang_telemetry.js]
 [browser_realm_key_and_document_domain.js]
diff --git a/js/xpconnect/tests/browser/browser_freeze_builtins.js b/js/xpconnect/tests/browser/browser_freeze_builtins.js
new file mode 100644
index 0000000000000..0047474ccfbcc
--- /dev/null
+++ b/js/xpconnect/tests/browser/browser_freeze_builtins.js
@@ -0,0 +1,27 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+function checkCtor(global, name, description) {
+  ok(Object.isFrozen(global[name]), `${description} ${name} is frozen`);
+  ok(
+    Object.isSealed(global[name].prototype),
+    `${description} ${name}.prototype is sealed`
+  );
+
+  let descr = Object.getOwnPropertyDescriptor(global, name);
+  ok(!descr.configurable, `${description} ${name} should be non-configurable`);
+  ok(!descr.writable, `${description} ${name} should not be writable`);
+}
+
+function checkGlobal(global, description) {
+  checkCtor(global, "Object", description);
+  checkCtor(global, "Array", description);
+  checkCtor(global, "Function", description);
+}
+
+add_task(async function() {
+  let systemGlobal = Cu.getGlobalForObject(Services);
+  checkGlobal(systemGlobal, "system global");
+});

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits