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.63.x) (#21843)

Uplift of #21813 (squashed) to beta
  • Loading branch information
brave-builds authored Feb 2, 2024
1 parent 942b6bc commit c519a67
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 @@ -2423,7 +2423,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 @@ -46,7 +46,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 c519a67

Please sign in to comment.