MicrosoftEdge / MicrosoftEdge/WebView2Samples

Question: Object.freeze(Object) usage within sample

Open
#173 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C++
Stars
1k
Forks
521
Avg merge
13m
Merged PRs (30d)
1

Description

The "most basic" sample Win32_GettingStarted includes this line

// <Scripting>
// Step 5 - Scripting
// Schedule an async task to add initialization script that freezes the Object object
webview->AddScriptToExecuteOnDocumentCreated(L"Object.freeze(Object);", nullptr);

This line of javascript freezes the Object prototype, making it immutable. This causes any website which includes polyfills that extend the Object prototype to throw an error (and presumably not render anything). Polyfills are common place in web development. (More details https://github.com/MicrosoftEdge/WebView2Feedback/issues/2035).

Is there a specific reason this sample recommends freezing the Object prototype?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with GettingStartedGuides/Win32_GettingStarted/HelloWebView.cpp around line 159 and review the linked WebView2Feedback issue 2035. Reproduce the sample with a site using an Object polyfill, then determine the rationale for freezing Object; done should be a documented explanation or a clearly justified sample change.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, javascript
Domain
desktop, web-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.