Skip to content

Feature policy implementation for gwt#5784

Merged
MrStahlfelge merged 5 commits into
libgdx:masterfrom
SimonIT:gwt-FeaturePolicy
Aug 27, 2020
Merged

Feature policy implementation for gwt#5784
MrStahlfelge merged 5 commits into
libgdx:masterfrom
SimonIT:gwt-FeaturePolicy

Conversation

@SimonIT

@SimonIT SimonIT commented Sep 3, 2019

Copy link
Copy Markdown
Member

With the feature policy, developers can allow and disallow some web browser features in iframes. If the game wants to access a disallowed feature, an error is thrown. This happens for example on itch.io. See for example the game of @MrStahlfelge for the game jam https://mrstahlfelge.itch.io/gdxjam1908. Make sure to use chrome. There will be an error in the console Uncaught (in promise) DOMException: Failed to construct 'Accelerometer': Access to sensor features is disallowed by feature policy
This PR adds a check whether the feature, in this case accelerometer, is allowed. If not isPeripheralAvailable returns false and the setupAccelerometer method wont get called.

https://developers.google.com/web/updates/2018/06/feature-policy
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Feature-Policy

@MrStahlfelge

Copy link
Copy Markdown
Member

Hi, can you put the html container site you tested with here? Makes it easier for me and others to test. Thanks. :)

@SimonIT

SimonIT commented Sep 4, 2019

Copy link
Copy Markdown
Member Author

Here's a live version https://libgdx2.v22018086706171227.nicesrv.de/
<iframe src="https://libgdx2.v22018086706171227.nicesrv.de/"></iframe>
You can add also some allow attributes for example <iframe src="https://libgdx2.v22018086706171227.nicesrv.de/" allow="accelerometer;"></iframe>
For a version without the fix remove the 2 behind libgdx
I placed here a site with two iframes with the fixed version. One without and one with allow attribute

@MrStahlfelge

Copy link
Copy Markdown
Member

Is there a specific reason why this doesn't get merged?

@MrStahlfelge MrStahlfelge merged commit 413e575 into libgdx:master Aug 27, 2020
@SimonIT SimonIT deleted the gwt-FeaturePolicy branch August 27, 2020 13:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants