Skip to content

Commit

Permalink
Support upcoming scriptletGlobals change in upstream uBO (uplift to…
Browse files Browse the repository at this point in the history
… 1.62.x) (#21846)

Uplift of #21813 (squashed) to release
  • Loading branch information
brave-builds authored Feb 2, 2024
1 parent 8fd3be5 commit 86f7366
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion browser/brave_shields/ad_block_service_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2384,7 +2384,7 @@ IN_PROC_BROWSER_TEST_F(ScriptletDebugLogsFlagEnabledTest, CanDebugSetToTrue) {
ASSERT_TRUE(InstallDefaultAdBlockExtension());
std::string scriptlet =
"(function() {"
" if (scriptletGlobals.get('canDebug')) {"
" if (scriptletGlobals.get('canDebug') && scriptletGlobals.canDebug) {"
" window.success = true;"
" }"
"})();";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const char kObservingScriptletEntryPoint[] =

const char kScriptletInitScript[] =
R"((function() {
let text = '(function() {\nconst scriptletGlobals = new Map(%s);\nlet deAmpEnabled = %s;\n' + %s + '})()';
let text = '(function() {\nconst scriptletGlobals = (() => {\nconst forwardedMapMethods = ["has", "get", "set"];\nconst handler = {\nget(target, prop) { if (forwardedMapMethods.includes(prop)) { return Map.prototype[prop].bind(target) } return target.get(prop); },\nset(target, prop, value) { if (!forwardedMapMethods.includes(prop)) { target.set(prop, value); } }\n};\nreturn new Proxy(new Map(%s), handler);\n})();\nlet deAmpEnabled = %s;\n' + %s + '})()';
let script;
try {
script = document.createElement('script');
Expand Down

0 comments on commit 86f7366

Please sign in to comment.