这是indexloc提供的服务,不要输入任何密码
Skip to content

Restrict JavaScript environment for Reusing FLEDGE Worklet Contexts #310

@brusshamilton

Description

@brusshamilton

On the Chrome implementation side, we’re looking at other options for reusing the JavaScript context for running worklets. One option we are pursuing and would like some feedback on is freezing the global object (equivalent to calling Object.Freeze recursively on globalThis and its properties) before running any scripts. This, combined with some other changes to script local storage would prevent worklet functions from persisting information between runs, so we can reuse the context for any interest groups that use the same bidding script.

If we freeze the global context, some JavaScript changes will be necessary:

  1. Global variable definitions through var and function definitions function generateBid(...) {..} will not be allowed. Instead use script-level definitions through let or const, defining worklet functions like: const generateBid = function(...) {...};.

Instead of these:

  • var x = …

  • function generateBid(...) {...}

  • globalThis.generateBid = function(...) {...}

Use these:

  • let x = … or const x = …

  • const generateBid = function(...) {...};

  1. "Overwriting" a property on an object whose prototype is frozen may not work as expected.

Instead of this:

let e = Error(“foo”);
e.name = “bar”; // this line will throw a TypeError

Use this:

let e = Error(“foo”);
Object.defineProperty(e, “name”, {value: “foo”});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions