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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add durableStorage to allowed permissions #5295

Merged
merged 4 commits into from Sep 16, 2021
Merged

Conversation

mushishi78
Copy link
Contributor

Please tell me if I've got the wrong end of the stick, I'm totally operating under guess work. I'd like to be able to use indexeddb. I've found "durableStorage" here.

I can also see it in the dart puppeteer docs (along with a bunch of others).

So I was hoping it was as simple as just adding to this list 馃

@googlebot
Copy link

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

馃摑 Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here with @googlebot I signed it! and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

鈩癸笍 Googlers: Go here for more info.

@mushishi78
Copy link
Contributor Author

@googlebot I signed it!

@googlebot
Copy link

CLAs look good, thanks!

鈩癸笍 Googlers: Go here for more info.

Copy link
Contributor

@jschfflr jschfflr left a comment

Choose a reason for hiding this comment

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

@mushishi78 Thanks for your contribution! Could you add the new permission to the documentation and maybe also find a way to add a test for this? Happy to get this landed :)

@mushishi78
Copy link
Contributor Author

@jschfflr added to docs and test. It's a bit low effort copy and paste, but possibly good enough? 馃

@mushishi78
Copy link
Contributor Author

@jschfflr And now rebased on main

Copy link
Contributor

@jschfflr jschfflr left a comment

Choose a reason for hiding this comment

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

Looks good to me, thanks!

@jschfflr jschfflr enabled auto-merge (squash) September 11, 2021 20:48
@jschfflr
Copy link
Contributor

@jschfflr added to docs and test. It's a bit low effort copy and paste, but possibly good enough? 馃

Looks good enough to me, thanks!

@mushishi78
Copy link
Contributor Author

Seems like the test failed on CI 馃槥

@jschfflr
Copy link
Contributor

It looks like getPermission is using navigator.permissions.query({ name }).then((result) => result.state) internally and the durable storage thing is not exposed by that. So instead, you should probably test if access to indexeddb is granted with the permission enabled.

@jschfflr
Copy link
Contributor

@mushishi78 I just tried to write a test for this usecase:

itFailsFirefox('should grant durable-storage', async () => {
      const { page, server, context } = getTestState();

      function checkIfIndexedDBIsAvailable() {
        const request = window.indexedDB.open("MyTestDatabase", 1);
        return new Promise((resolve, reject) => {
          request.onsuccess = () => resolve(true);
          request.onerror = (err) => reject(err);
        });
      }

      await context.clearPermissionOverrides();
      await page.goto(server.EMPTY_PAGE);
      expect(await page.evaluate(checkIfIndexedDBIsAvailable)).toBe(false);
      await context.overridePermissions(server.EMPTY_PAGE, ['durable-storage']);
      expect(await page.evaluate(checkIfIndexedDBIsAvailable)).toBe(true);
      await context.clearPermissionOverrides();
    });

but it looks like the durable-storage permission is not needed to create the indexedDB instance. Could you verify that this unit test actually tests the problem that you ran into?

@mushishi78
Copy link
Contributor Author

Thanks @jschfflr. The problem for me is only when not in headless if that helps. Whenever I debug my tests I have to manually press accept on the permission.

@jschfflr
Copy link
Contributor

@mushishi78 Could you share the code that you are running? Or a minimal reproduction?
I tried running HEADLESS=0 npm run unit -- -g "should grant durable-storage" but it didn't ask for permission either :/

@mushishi78
Copy link
Contributor Author

That's frustrating. I'm going on holiday until next monday, so won't have time to until sometime next week unfortuneately. Thanks for your help.

@google-cla
Copy link

google-cla bot commented Sep 16, 2021

All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter.

We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only @googlebot I consent. in this pull request.

Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the cla label to yes (if enabled on your project).

鈩癸笍 Googlers: Go here for more info.

@google-cla google-cla bot added cla: no and removed cla: yes labels Sep 16, 2021
@jschfflr
Copy link
Contributor

I took a look at this change again and the underlying permissions. It looks like durableStorage maps to persistent-storage in the permission api. I therefore changed this patch to use persistent-storage instead of durable-storage. Let me know what you think!

Regarding the indexedDB test - the permission is probably only needed if the indexeddb reaches a certain since which is not the case for the test.

That's frustrating. I'm going on holiday until next monday, so won't have time to until sometime next week unfortuneately. Thanks for your help.

Have a great time off! Let me know if you're happy with the change as it is now and I'll get it merged :)

@google-cla
Copy link

google-cla bot commented Sep 16, 2021

All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter.

We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only @googlebot I consent. in this pull request.

Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the cla label to yes (if enabled on your project).

鈩癸笍 Googlers: Go here for more info.

@jschfflr
Copy link
Contributor

@googlebot I consent.

@googlebot
Copy link

All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter.

We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only @googlebot I consent. in this pull request.

Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the cla label to yes (if enabled on your project).

鈩癸笍 Googlers: Go here for more info.

mushishi78 and others added 4 commits September 16, 2021 12:16
Please tell me if I've got the wrong end of the stick, I'm totally operating under guess work. I'd like to be able to use indexeddb. I've found "durableStorage" [here](https://chromium-review.googlesource.com/c/chromium/src/+/1185877/4/content/browser/devtools/protocol/browser_handler.cc#120).

I can also see it in the dart puppeteer: https://pub.dev/documentation/puppeteer/latest/protocol_browser/PermissionType-class.html (along with a bunch of others).

So I was hoping it was as simple as just adding to this list.
@google-cla
Copy link

google-cla bot commented Sep 16, 2021

CLAs look good, thanks!

鈩癸笍 Googlers: Go here for more info.

@google-cla google-cla bot added cla: yes and removed cla: no labels Sep 16, 2021
@googlebot
Copy link

CLAs look good, thanks!

鈩癸笍 Googlers: Go here for more info.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants