Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop iterating over window props #4745

Closed
4 tasks done
PaperStrike opened this issue Sep 11, 2021 · 5 comments · Fixed by #4746
Closed
4 tasks done

Stop iterating over window props #4745

PaperStrike opened this issue Sep 11, 2021 · 5 comments · Fixed by #4746
Labels
area: browser browser-specific type: bug a defect, confirmed by a maintainer

Comments

@PaperStrike
Copy link
Contributor

PaperStrike commented Sep 11, 2021

Prerequisites

  • Checked that your issue hasn't already been filed by cross-referencing issues with the faq label
  • Checked next-gen ES issues and syntax problems by using the same environment and/or transpiler configuration without Mocha to ensure it isn't just a feature that actually isn't supported in the environment in question or a bug in your code.
  • 'Smoke tested' the code to be tested by running it outside the real test suite to get a better sense of whether the problem is in the code under test, your usage of Mocha, or Mocha itself
  • Ensured that there is no discrepancy between the locally and globally installed versions of Mocha. You can find them with: node node_modules/.bin/mocha --version(Local) and mocha --version(Global). We recommend that you not install Mocha globally.

Description

module.exports = Object.assign(mocha, global);

is causing chrome to show a 'window.webkitStorageInfo' is deprecated. warning.

To my understanding, iterating over the window properties is only for the check-leaks feature. Then with this feature disabled, there is no need to iterate that.

There is no need to access all the global variables.

Thank you.

Steps to Reproduce

Run any mocha test in a recent Chrome.

Expected behavior: No access to every global variables.

Actual behavior: At least one access to each global variable.

Reproduces how often: Every time you run mocha.

Versions

  • The output of mocha --version and node node_modules/.bin/mocha --version: 9.1.0
  • The output of node --version: 14.17.0
  • Your browser and version (if running browser tests): Chrome Dev 94.0.4595.0 with Playwright

Additional Information

@juergba
Copy link
Contributor

juergba commented Sep 11, 2021

Yes, I have seen this warning window.webkitStorageInfo is deprecated.
Blaming mocha/browser-entry.js and studying the listed PRs, I don't find any reasons for your check-leaks pretention.
Any help would be appreciated.

Are you bundling yourself, or do you use our browser bundle mocha.js or mocha-es2018.js?

@juergba juergba added area: browser browser-specific status: accepting prs Mocha can use your help with this one! labels Sep 11, 2021
@PaperStrike
Copy link
Contributor Author

I'm using playwright-test, you can consider it as bundling by myself. Sorry for the expressions, for check-leaks I mean the --check-leaks option. The reason I guess why Mocha iterates all the global vars is for this option.

Is it necessary to iterate the window props when there's no need to check their leaks?

@PaperStrike
Copy link
Contributor Author

PaperStrike commented Sep 11, 2021

If the --check-leaks option is implemented in a totally unrelated way, then ignore my words on it. The file should directly export mocha without the Object.assign.

@PaperStrike
Copy link
Contributor Author

A quick dirty fix:

module.exports = Object.assign(mocha, global);

to

[
  'Mocha',
  'after',
  'afterEach',
  'before',
  'beforeEach',
  'context',
  'describe',
  'it',
  'mocha',
  'run',
  'setup',
  'specify',
  'suite',
  'suiteSetup',
  'suiteTeardown',
  'teardown',
  'test',
  'xcontext',
  'xdescribe',
  'xit',
  'xspecify'
].forEach(function(key) {
  mocha[key] = global[key];
});
module.exports = mocha;

@PaperStrike PaperStrike changed the title Stop iterating over the globals when not checking leaks Stop accessing all global variables Sep 11, 2021
@PaperStrike PaperStrike changed the title Stop accessing all global variables Stop accessing every global variable Sep 11, 2021
@PaperStrike PaperStrike changed the title Stop accessing every global variable Stop iterating over window props Sep 11, 2021
@juergba
Copy link
Contributor

juergba commented Sep 14, 2021

probably related issue #4740

@juergba juergba added type: bug a defect, confirmed by a maintainer and removed unconfirmed-bug status: accepting prs Mocha can use your help with this one! labels Sep 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: browser browser-specific type: bug a defect, confirmed by a maintainer
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants