fix(webkit): improve orientation detection (#11481)

This commit is contained in:
Pavel Feldman 2022-01-19 10:07:38 -08:00 committed by GitHub
parent 82c8baf9f6
commit a65f7066d5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 16 additions and 0 deletions

View File

@ -732,6 +732,11 @@ export class WKPage implements PageDelegate {
private _calculateBootstrapScript(): string { private _calculateBootstrapScript(): string {
const scripts: string[] = []; const scripts: string[] = [];
if (!this._page.context()._options.isMobile) {
scripts.push('delete window.orientation');
scripts.push('delete window.ondevicemotion');
scripts.push('delete window.ondeviceorientation');
}
for (const binding of this._page.allBindings()) for (const binding of this._page.allBindings())
scripts.push(this._bindingToScript(binding)); scripts.push(this._bindingToScript(binding));
scripts.push(...this._browserContext._evaluateOnNewDocumentSources); scripts.push(...this._browserContext._evaluateOnNewDocumentSources);

View File

@ -10,6 +10,11 @@ for (const name in Modernizr) {
let value = Modernizr[name]; let value = Modernizr[name];
report[name] = value; report[name] = value;
} }
report['devicemotion2'] = 'ondevicemotion' in window;
report['deviceorientation2'] = 'orientation' in window;
report['deviceorientation3'] = 'ondeviceorientation' in window;
document.body.style.whiteSpace = 'pre'; document.body.style.whiteSpace = 'pre';
document.body.textContent = JSON.stringify(report, undefined, 4); document.body.textContent = JSON.stringify(report, undefined, 4);
window.report = JSON.parse(document.body.textContent); window.report = JSON.parse(document.body.textContent);

View File

@ -90,7 +90,10 @@
"promises": true, "promises": true,
"es6string": true, "es6string": true,
"devicemotion": true, "devicemotion": true,
"devicemotion2": true,
"deviceorientation": true, "deviceorientation": true,
"deviceorientation2": true,
"deviceorientation3": true,
"filereader": true, "filereader": true,
"urlparser": true, "urlparser": true,
"urlsearchparams": true, "urlsearchparams": true,

View File

@ -90,7 +90,10 @@
"promises": true, "promises": true,
"es6string": true, "es6string": true,
"devicemotion": false, "devicemotion": false,
"devicemotion2": false,
"deviceorientation": false, "deviceorientation": false,
"deviceorientation2": false,
"deviceorientation3": false,
"filereader": true, "filereader": true,
"urlparser": true, "urlparser": true,
"urlsearchparams": true, "urlsearchparams": true,