GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — lib: add navigator.platform by Uzlopak · Pull Request #50385 · nodejs/node

Conversation

@Uzlopak

@Uzlopak Uzlopak commented Oct 25, 2023

Copy link
Copy Markdown
Contributor

adds navigator.platform

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

bricss and zm-cttae reacted with thumbs up emoji
All reactions
  • 👍 2 reactions
@nodejs-github-bot nodejs-github-bot added the needs-ci PRs that need a full CI run. label Oct 25, 2023
@Uzlopak

Uzlopak commented Oct 25, 2023

Copy link
Copy Markdown
Contributor Author

@zm-cttae
@anonrig

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Uzlopak
Uzlopak force-pushed the navigator-platform branch from 0667117 to 42b169f Compare October 25, 2023 11:57
tniessen
tniessen reviewed Oct 25, 2023
View reviewed changes

@tniessen tniessen left a comment •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW, while this is somewhat standardized, even Deno hasn't implemented it, and the top of the MDN page clearly discourages its use:

This feature is no longer recommended. Though some browsers might still support it, it may have already been removed from the relevant web standards, may be in the process of being dropped, or may only be kept for compatibility purposes. Avoid using it, and update existing code if possible (..). Be aware that this feature may cease to work at any time.

I suppose this PR is in line with the option to "add more ancient HTML properties" as outlined in #50269 (comment), so if that's the direction the project is going... 🤷

(FWIW, it would also be spec-compliant to return some useless/incorrect value or potentially even an empty string.)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread doc/api/globals.md Resolved

Uh oh!

There was an error while loading. Please reload this page.

@tniessen tniessen added experimental Issues and PRs related to experimental features. semver-minor PRs that contain new features and should be released in the next minor version. labels Oct 25, 2023
@Uzlopak

Uzlopak commented Oct 25, 2023 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

The MDN is not a reliable source regarding the deprecation of those properties. They only mark it as deprecated because they can not mark something as "avoid as best as you can".

Also it is not It is not spec compliant to return an empty string. See whatwg/html#7762

Even Typescript considers the deprecation as a bug:
microsoft/TypeScript#49683

See also for more insights:
mdn/content#14429

It is part of whatwg testing:
https://github.com/web-platform-tests/wpt/blob/72e06c82933e9d324881b756a3fc48a3cac1c09d/workers/interfaces/WorkerUtils/navigator/004.js

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@tniessen

tniessen commented Oct 25, 2023

Copy link
Copy Markdown
Member

The MDN is not a reliable source regarding the deprecation of those properties. They only mark it as deprecated because they can not mark something as "avoid as best as you can".

I did not use the word "deprecation". If the intended meaning is "avoid as best as you can", as you put it, that is precisely what I am referring to. Node.js applications worked just fine without this property for far more than a decade.

It is not spec compliant to return an empty string.

You are right, the spec was changed a while ago. Instead, it is spec-compliant to return an incorrect value now...

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Uzlopak

Uzlopak commented Oct 26, 2023

Copy link
Copy Markdown
Contributor Author

@anonrig
@aduh95

Can someome please retrigger macos build? The build error should be independent from this PR.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@GeoffreyBooth GeoffreyBooth added the web-standards Issues and PRs related to web-platform APIs and standards compliance. label Oct 26, 2023
GeoffreyBooth
GeoffreyBooth reviewed Oct 26, 2023
View reviewed changes
Comment thread lib/internal/navigator.js Resolved

Uh oh!

There was an error while loading. Please reload this page.

@GeoffreyBooth

GeoffreyBooth commented Oct 26, 2023

Copy link
Copy Markdown
Member

The MDN is not a reliable source regarding the deprecation of those properties. They only mark it as deprecated because they can not mark something as “avoid as best as you can”.

I skimmed the referenced links but I can’t find an answer to why MDN wants to discourage it. Reading https://developer.mozilla.org/en-US/docs/Web/API/Navigator/platform it seems like they discourage its use simply because they recommend using feature detection rather than platform detection; is that your guess as well?

I think for Node’s case, sure feature detection is always preferable whenever possible but we have plenty of use cases that absolutely need platform detection, such as choosing a particular binary to run. We don’t discourage the use of process.platform, after all. So I think it would be good for us to add this, to give developers a cross-runtime way of doing platform detection.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@GeoffreyBooth

GeoffreyBooth commented Oct 26, 2023

Copy link
Copy Markdown
Member

Let’s please ping @nodejs/web-standards for all issues and PRs related to navigator.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@GeoffreyBooth

GeoffreyBooth commented Oct 26, 2023

Copy link
Copy Markdown
Member

Yes, it seems to be very similar to #50385 (comment). In either case, it’s not clear why MDN is intending to discourage the use of this API, other than perhaps because they think feature detection is a better approach in general. Is that your impression or is there some other reason?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@tniessen

tniessen commented Oct 26, 2023

Copy link
Copy Markdown
Member

it seems like they discourage its use simply because they recommend using feature detection rather than platform detection; is that your guess as well?

@GeoffreyBooth I think that's the main idea, but the spec also allows browser to return entirely incorrect values for privacy, so developers should not rely on navigator.platform in any case.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Uzlopak

Uzlopak commented Oct 26, 2023

Copy link
Copy Markdown
Contributor Author

Reading https://developer.mozilla.org/en-US/docs/Web/API/Navigator/platform it seems like they discourage its use simply because they recommend using feature detection rather than platform detection; is that your guess as well?

Yes, I think so too.

Btw. I am willing to add more attributes, but some stuff seems odd, like navigator.appName is always 'Navigator' for compatibility reasons. So should it be also added? So yes, I hope we get to an agreement soon, so that we can finish this object as best as possible.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@GeoffreyBooth

GeoffreyBooth commented Oct 26, 2023

Copy link
Copy Markdown
Member

I think we can keep adding properties regardless of what other PRs are floating out there. No one has put up a PR to fully delete the global, just to flag it, so even if it gets flagged it should still have whatever properties we think it should have.

I’m inclined to add platform and really any other property that makes even remote sense, because it’s better to have a property exist than not, for code that might break when checking for it and assuming its existence.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

GeoffreyBooth
GeoffreyBooth approved these changes Oct 26, 2023
View reviewed changes
@nodejs-github-bot

nodejs-github-bot commented Oct 27, 2023

Copy link
Copy Markdown
Collaborator

CI: https://ci.nodejs.org/job/node-test-pull-request/55271/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

anonrig
anonrig approved these changes Oct 27, 2023
View reviewed changes
@Uzlopak

Uzlopak commented Oct 27, 2023

Copy link
Copy Markdown
Contributor Author

Hmm. I consider to work again on this in few hours.

creating a new function called getNavigatorPlatform, which expects an optional parameter of shape { platform, arch }, which by default gets process.
Then I can test it by providing mocks into the function and having 100% test coverage.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot mentioned this pull request Oct 28, 2023
CI Reliability 2023-10-28 nodejs/reliability#700
Open
22 tasks
@nodejs-github-bot

nodejs-github-bot commented Oct 28, 2023

Copy link
Copy Markdown
Collaborator

CI: https://ci.nodejs.org/job/node-test-pull-request/55276/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@GeoffreyBooth

GeoffreyBooth commented Oct 28, 2023

Copy link
Copy Markdown
Member

Then I can test it by providing mocks into the function and having 100% test coverage.

I don’t think this is necessary. Our CI already runs the test suite on every supported platform, so every branch of the if is already getting checked, albeit not in the same run.

Ideally that last assertion, for the miscellaneous Linux platforms, would assert against plain strings but it would be a pain to figure out what all of those should be. You could assert against a temporary string like ‘TODO’ and I can run CI and you can look at the CI output on each failing platform to see what the string could be for that platform, and then we can put that in here. I’m not sure it’s worth the effort though.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@zm-cttae

zm-cttae commented Oct 28, 2023

Copy link
Copy Markdown

It appears that platform is also a valid part of the spec.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@zm-cttae zm-cttae mentioned this pull request Oct 28, 2023
navigator object breaks projects in v21.0.0 #50269
Closed
@Uzlopak
Uzlopak force-pushed the navigator-platform branch 2 times, most recently from 961a62f to 66e2ffc Compare October 28, 2023 12:57
@jasnell

jasnell commented Oct 28, 2023

Copy link
Copy Markdown
Member

This one I'm genuinely not convinced we should export. As has been pointed out in discussion there are a number of issues with this, not the least of which being that even browsers recommend against relying on it. I note that bun implements it but deno doesn't. That said, a quick code search on github shows 66k JS files using this for various purposes so perhaps it is worthwhile? @Uzlopak ... can you expand a bit on the use case you have in mind for this?

tniessen reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@zm-cttae

zm-cttae commented Oct 28, 2023

Copy link
Copy Markdown

The reason it was implemented was because Next.js relies on the prop when Navigator is available globally.

jasnell reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@nodejs-github-bot

nodejs-github-bot commented Nov 2, 2023

Copy link
Copy Markdown
Collaborator

CI: https://ci.nodejs.org/job/node-test-pull-request/55429/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Uzlopak

Uzlopak commented Nov 2, 2023

Copy link
Copy Markdown
Contributor Author

@GeoffreyBooth

image

Please merge :)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Uzlopak

Uzlopak commented Nov 2, 2023

Copy link
Copy Markdown
Contributor Author

Or maybe @H4ad ?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@H4ad H4ad added commit-queue PRs queued for automated landing through the Commit Queue. and removed commit-queue-failed PRs whose Commit Queue landing failed and need manual intervention before retrying. commit-queue-squash PRs the Commit Queue should land as one squashed commit. labels Nov 2, 2023
@nodejs-github-bot nodejs-github-bot removed the commit-queue PRs queued for automated landing through the Commit Queue. label Nov 2, 2023
@nodejs-github-bot
nodejs-github-bot merged commit a450eed into nodejs:main Nov 2, 2023
@nodejs-github-bot

nodejs-github-bot commented Nov 2, 2023

Copy link
Copy Markdown
Collaborator

Landed in a450eed

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Uzlopak
Uzlopak deleted the navigator-platform branch November 2, 2023 20:21
@github-actions github-actions Bot mentioned this pull request Nov 3, 2023
CI Reliability 2023-11-03 nodejs/reliability#706
Open
22 tasks
@legendecas legendecas mentioned this pull request Nov 3, 2023
Navigator APIs WinterTC55/proposal-minimum-common-api#61
Closed
This was referenced Nov 4, 2023
CI Reliability 2023-11-04 nodejs/reliability#707
Open
CI Reliability 2023-11-05 nodejs/reliability#708
Open
CI Reliability 2023-11-06 nodejs/reliability#709
Open
CI Reliability 2023-11-07 nodejs/reliability#710
Open
CI Reliability 2023-11-08 nodejs/reliability#711
Open
CI Reliability 2023-11-09 nodejs/reliability#712
Open
targos pushed a commit that referenced this pull request Nov 11, 2023
@Uzlopak @targos
lib: add navigator.platform
49ad916
PR-URL: #50385
Reviewed-By: Geoffrey Booth <[email protected]>
Reviewed-By: Yagiz Nizipli <[email protected]>
Reviewed-By: James M Snell <[email protected]>
targos added a commit that referenced this pull request Nov 12, 2023
@targos
2023-11-14, Version 21.2.0 (Current)
9183a07
Notable changes:

doc:
  * add MrJithil to collaborators (Jithil P Ponnan) #50666
  * add Ethan-Arrowood as a collaborator (Ethan Arrowood) #50393
esm:
  * (SEMVER-MINOR) add import.meta.dirname and import.meta.filename (James Sumners) #48740
fs:
  * add stacktrace to fs/promises (翠 / green) #49849
lib:
  * (SEMVER-MINOR) add navigator.platform (Aras Abbasi) #50385
stream:
  * (SEMVER-MINOR) add support for `deflate-raw` format to webstreams compression (Damian Krzeminski) #50097
  * use Array for Readable buffer (Robert Nagy) #50341
  * optimize creation (Robert Nagy) #50337
test_runner:
  * adds built in lcov reporter (Phil Nash) #50018
  * (SEMVER-MINOR) add Date to the supported mock APIs (Lucas Santos) #48638
test_runner, cli:
  * (SEMVER-MINOR) add --test-timeout flag (Shubham Pandey) #50443

PR-URL: #50681
@targos targos mentioned this pull request Nov 12, 2023
v21.2.0 release proposal #50681
Merged
targos added a commit that referenced this pull request Nov 13, 2023
@targos
2023-11-14, Version 21.2.0 (Current)
0f82899
Notable changes:

doc:
  * add MrJithil to collaborators (Jithil P Ponnan) #50666
  * add Ethan-Arrowood as a collaborator (Ethan Arrowood) #50393
esm:
  * (SEMVER-MINOR) add import.meta.dirname and import.meta.filename (James Sumners) #48740
fs:
  * add stacktrace to fs/promises (翠 / green) #49849
lib:
  * (SEMVER-MINOR) add `--no-experimental-global-navigator` CLI flag (Antoine du Hamel) #50562
  * (SEMVER-MINOR) add navigator.language & navigator.languages (Aras Abbasi) #50303
  * (SEMVER-MINOR) add navigator.platform (Aras Abbasi) #50385
stream:
  * (SEMVER-MINOR) add support for `deflate-raw` format to webstreams compression (Damian Krzeminski) #50097
  * use Array for Readable buffer (Robert Nagy) #50341
  * optimize creation (Robert Nagy) #50337
test_runner:
  * (SEMVER-MINOR) adds built in lcov reporter (Phil Nash) #50018
  * (SEMVER-MINOR) add Date to the supported mock APIs (Lucas Santos) #48638
test_runner, cli:
  * (SEMVER-MINOR) add --test-timeout flag (Shubham Pandey) #50443

PR-URL: #50681
targos pushed a commit that referenced this pull request Nov 14, 2023
@Uzlopak @targos
lib: add navigator.platform
f932f4c
PR-URL: #50385
Reviewed-By: Geoffrey Booth <[email protected]>
Reviewed-By: Yagiz Nizipli <[email protected]>
Reviewed-By: James M Snell <[email protected]>
targos added a commit that referenced this pull request Nov 14, 2023
@targos
2023-11-14, Version 21.2.0 (Current)
13b266f
Notable changes:

doc:
  * add MrJithil to collaborators (Jithil P Ponnan) #50666
  * add Ethan-Arrowood as a collaborator (Ethan Arrowood) #50393
esm:
  * (SEMVER-MINOR) add import.meta.dirname and import.meta.filename (James Sumners) #48740
fs:
  * add stacktrace to fs/promises (翠 / green) #49849
lib:
  * (SEMVER-MINOR) add `--no-experimental-global-navigator` CLI flag (Antoine du Hamel) #50562
  * (SEMVER-MINOR) add navigator.language & navigator.languages (Aras Abbasi) #50303
  * (SEMVER-MINOR) add navigator.platform (Aras Abbasi) #50385
stream:
  * (SEMVER-MINOR) add support for `deflate-raw` format to webstreams compression (Damian Krzeminski) #50097
  * use Array for Readable buffer (Robert Nagy) #50341
  * optimize creation (Robert Nagy) #50337
test_runner:
  * (SEMVER-MINOR) adds built in lcov reporter (Phil Nash) #50018
  * (SEMVER-MINOR) add Date to the supported mock APIs (Lucas Santos) #48638
test_runner, cli:
  * (SEMVER-MINOR) add --test-timeout flag (Shubham Pandey) #50443

PR-URL: #50681
targos added a commit that referenced this pull request Nov 14, 2023
@targos
2023-11-14, Version 21.2.0 (Current)
02db7fc
Notable changes:

doc:
  * add MrJithil to collaborators (Jithil P Ponnan) #50666
  * add Ethan-Arrowood as a collaborator (Ethan Arrowood) #50393
esm:
  * (SEMVER-MINOR) add import.meta.dirname and import.meta.filename (James Sumners) #48740
fs:
  * add stacktrace to fs/promises (翠 / green) #49849
lib:
  * (SEMVER-MINOR) add `--no-experimental-global-navigator` CLI flag (Antoine du Hamel) #50562
  * (SEMVER-MINOR) add navigator.language & navigator.languages (Aras Abbasi) #50303
  * (SEMVER-MINOR) add navigator.platform (Aras Abbasi) #50385
stream:
  * (SEMVER-MINOR) add support for `deflate-raw` format to webstreams compression (Damian Krzeminski) #50097
  * use Array for Readable buffer (Robert Nagy) #50341
  * optimize creation (Robert Nagy) #50337
test_runner:
  * (SEMVER-MINOR) adds built in lcov reporter (Phil Nash) #50018
  * (SEMVER-MINOR) add Date to the supported mock APIs (Lucas Santos) #48638
test_runner, cli:
  * (SEMVER-MINOR) add --test-timeout flag (Shubham Pandey) #50443

PR-URL: #50681
@richardlau richardlau added the dont-land-on-v20.x label Mar 25, 2024
@kt3k kt3k mentioned this pull request Jun 6, 2024
Add navigator.platform denoland/deno#24117
Closed
@skyclouds2001 skyclouds2001 mentioned this pull request Nov 7, 2024
Add nodejs data for Navigator mdn/browser-compat-data#24988
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@tniessen tniessen tniessen left review comments
@richardlau richardlau richardlau left review comments
@jasnell jasnell jasnell approved these changes
@GeoffreyBooth GeoffreyBooth GeoffreyBooth approved these changes
@anonrig anonrig anonrig approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

author ready PRs with CI started, the required approvals, and no outstanding review comments. experimental Issues and PRs related to experimental features. needs-ci PRs that need a full CI run. semver-minor PRs that contain new features and should be released in the next minor version. web-standards Issues and PRs related to web-platform APIs and standards compliance.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

10 participants

@Uzlopak @tniessen @GeoffreyBooth @nodejs-github-bot @zm-cttae @jasnell @targos @anonrig @richardlau @H4ad
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.