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

test: add test for synchronous access to blink APIs #14637

Merged
merged 1 commit into from
Sep 24, 2018

Conversation

MarshallOfSound
Copy link
Member

This test should ensure we catch a regression of #13787

Notes: no-notes

@MarshallOfSound MarshallOfSound requested a review from a team September 15, 2018 16:04
Copy link
Member

@deepak1556 deepak1556 left a comment

Choose a reason for hiding this comment

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

LGTM with some minor changes, thanks for adding this!

@@ -1286,6 +1286,21 @@ describe('BrowserWindow module', () => {
})
w.loadFile(path.join(fixtures, 'api', 'preload.html'))
})
it('has access to blink APIs', (done) => {
Copy link
Member

Choose a reason for hiding this comment

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

Can you move this spec to chromium-spec.js, we have been isolating any Web standard api specific testing in there.

Also the original issue was delay loading of some these apis after the script context was created, so it would be good to rewrite this test such that it populates all apis on the window object in the preload as well as in the load web page, compare that there are no differences in the result. Which would basically ensure #13787 (comment) spec.

Also, since these are not blink specific apis, might be worth rewording as has no difference with features on window object before and after context creation

Copy link
Member Author

Choose a reason for hiding this comment

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

Also the original issue was delay loading of some these apis after the script context was created, so it would be good to rewrite this test such that it populates all apis on the window object in the preload as well as in the load web page

Yup this makes sense

Can you move this spec to chromium-spec.js

preload scripts aren't chromium features though? I think it should go in the preload section where it is now

Copy link
Member

Choose a reason for hiding this comment

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

preload scripts aren't chromium features though? I think it should go in the preload section where it is now

Yeah, I was looking at the features it was testing and decided to go with chromium-spec, sounds good to have it here.

@MarshallOfSound MarshallOfSound changed the title spec: add test for syncronous access to blink APIs spec: add test for synchronous access to blink APIs Sep 16, 2018
@MarshallOfSound MarshallOfSound changed the title spec: add test for synchronous access to blink APIs test: add test for synchronous access to blink APIs Sep 16, 2018
done()
})
w.destroy()
w = new BrowserWindow({
Copy link
Contributor

Choose a reason for hiding this comment

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

Please use openTheWindow() from this file to open a new window.
"Global" w should eventually be removed.

const preload = <...>
const w = await openTheWindow({<...>})
w.loadFile(<...>)
const [, test] = await emittedOnce(ipcMain, 'answer')

expect(test).to.be.an('object')
expect(test).to.have.own.property('atPreload').that.is.an('array')
expect(test).to.have.own.property('atLoad').that.is.an('array')
<...>

Copy link
Contributor

@alexeykuzmin alexeykuzmin left a comment

Choose a reason for hiding this comment

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

👍

})
w.loadFile(path.join(fixtures, 'api', 'preload.html'))
const [, test] = await emittedOnce(ipcMain, 'answer')
expect(test).to.be.ok('object')
Copy link
Contributor

Choose a reason for hiding this comment

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

It should be .to.be.an('object'), not .to.be.ok.

const [, test] = await emittedOnce(ipcMain, 'answer')
expect(test).to.be.ok('object')
expect(test.atPreload).to.be.a('array')
expect(test.atLoad).to.be.a('array')
Copy link
Contributor

Choose a reason for hiding this comment

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

.an('array') is probably better than a.('array') =)

This test should ensure we catch a regression of #13787
@MarshallOfSound
Copy link
Member Author

@alexeykuzmin PR updated 👍

Copy link
Contributor

@alexeykuzmin alexeykuzmin left a comment

Choose a reason for hiding this comment

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

👍

@MarshallOfSound MarshallOfSound merged commit 50a4a8e into master Sep 24, 2018
@release-clerk
Copy link

release-clerk bot commented Sep 24, 2018

No Release Notes

@MarshallOfSound MarshallOfSound deleted the add-preload-spec branch September 24, 2018 22:40
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.

None yet

4 participants