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

Support for SlimerJS #483

Merged
merged 38 commits into from Jul 13, 2013

Conversation

Projects
None yet
5 participants
@laurentj
Collaborator

laurentj commented May 21, 2013

These changes allow to launch scripts with SlimerJS instead of PhantomJS.

Note that tests on CasperJS are not green yet when launching it with SlimerJS, because of missing features into SlimerJS.

laurentj added some commits May 4, 2013

Fix bootstrap: global should be this, not window
In a javascript context, all JS function are not all attached to the window object.
This is the case of 'native' functions. In SlimerJS, the 'require' function is
not attached to the window object. It is a standalone function.
Bootstrap.js: specific support of patchRequire for SlimerJS
SlimerJS provides an API to indicate paths where modules
can be found: require.paths (CommonJS specification).
So patchRequire is not needed for SlimerJS.
refs #482: Adds an --engine=.. option
It will allow to choice different browser engines, instead of phantomjs
refs #482: supports of --engine=slimerjs
This options allows to use SlimerJS (gecko) instead of PhantomJS (webkit)
@n1k0

This comment has been minimized.

Show comment
Hide comment
@n1k0

n1k0 May 22, 2013

Member

Great stuff. I'll review the patch but it's looking good already.

I'll merge this as soon as the tests are green though.

Member

n1k0 commented May 22, 2013

Great stuff. I'll review the patch but it's looking good already.

I'll merge this as soon as the tests are green though.

@laurentj

This comment has been minimized.

Show comment
Hide comment
@laurentj

laurentj May 22, 2013

Collaborator

Tests are green. Travis CI fails only because of jshint that is not happy because I added two "if" statements, and because I added a line break on a line of code on an assignement. I can fix this last "issue", but should I really to refactorize the entire code of bootstrap.js just because of these two if???

Collaborator

laurentj commented May 22, 2013

Tests are green. Travis CI fails only because of jshint that is not happy because I added two "if" statements, and because I added a line break on a line of code on an assignement. I can fix this last "issue", but should I really to refactorize the entire code of bootstrap.js just because of these two if???

@laurentj

This comment has been minimized.

Show comment
Hide comment
@laurentj

laurentj May 22, 2013

Collaborator

Ok, no refactoring is needed, I just increased jshint parameters :)

Collaborator

laurentj commented May 22, 2013

Ok, no refactoring is needed, I just increased jshint parameters :)

@n1k0

This comment has been minimized.

Show comment
Hide comment
@n1k0

n1k0 Jun 2, 2013

Member

Please sync with latest master. Also, the rubybin/casperjs script should also reflect the changes made in bin/casperjs (poke @hannyu)

Member

n1k0 commented Jun 2, 2013

Please sync with latest master. Also, the rubybin/casperjs script should also reflect the changes made in bin/casperjs (poke @hannyu)

@laurentj

This comment has been minimized.

Show comment
Hide comment
@laurentj

laurentj Jun 2, 2013

Collaborator

Sorry, I never used Ruby and I don't have time to learn a new language ...

Collaborator

laurentj commented Jun 2, 2013

Sorry, I never used Ruby and I don't have time to learn a new language ...

@n1k0

This comment has been minimized.

Show comment
Hide comment
@n1k0

n1k0 Jun 3, 2013

Member

@laurentj me neither nor I want to.

If nobody wants to maintain the ruby exec, I'll probably get rid of it. I'll create an issue about this.

Member

n1k0 commented Jun 3, 2013

@laurentj me neither nor I want to.

If nobody wants to maintain the ruby exec, I'll probably get rid of it. I'll create an issue about this.

laurentj added some commits Jun 4, 2013

Refs #482: CasperJS should wait after the browser initialization
The call of webpage.open() (or openUrl()) is synchronous in PhantomJS,
but is asynchronous in SlimerJS (it needs to open a real window etc..).

So CasperJS should not launch the next step just after the call of
webpage.openUrl(). A flag is set to true before this call, and
then set to false when receiving the first event from the page loader.
And this flag has to be checked before to execute the next step.
Refs #482: colorizer: fixes a warning
With Gecko, a warning appears when an option does not exists
in styles.
Refs #482: selftest server should read png as binary file
PhantomJS has a strange behavior on fs.read: it seems it reads
file always as binary file. However SlimerJS's fs.read strictly
respect the 'b' flag. So the web server of selftest should
return content of binary files as... binary data. Else images
are not sent correctly to the browser and Gecko cannot display
them. and then some tests fail, like tests on assertVisible.
Refs #482: fixed a regression in clitests
One test of clitests loads about:blank. However, there
is no navigationRequested event and so our new browserInitializing
flag is not toggled to false, and then checkStep() is blocking
tests. Let's toggle it inside onLoadStarted too.
Fixes reference errors in testers.js
stackArray is not a standard property of the Error object. It is
added by PhantomJS (modification in the sources of QTWebkit).
We should use the stack property if stackArray is not present
(like in SlimerJS)
Refs #482: new property phantom.casperEngine storing the engine name
It will easier in the code to know the current engine.
Refs #482: fixes utils.betterTypeOf() for SlimerJS
In SlimerJS, the webpage object has no type 'qtruntimeobject' written
in the string form of the object. But it has a __type property.
The function should check this property when the engine is not PhantomJS.
Fixes an infinite loop with checkStep
the navigationRequested boolean should be false when the new URL
has only a difference on the hash part with the previous URL, because
in this case we don't have a loadStarted/loadFinished event (at least
with Gecko) and then navigationRequested cannot be turn into false.
The consequence is that checkStep doesn't execute the next step because
of its test on navigationRequested.
Refs #482: fixes utils.equals for gecko
Using instanceof is not enough for Gecko.
Fixes some tests for Gecko
- skip tests about javascript: links, because they are executed asynchronously
  so tests about them fails.
- event.x and event.y don't exist in Gecko. The standard way is event.clientX
  and event.clientY
Fixes #512: continue to the next step on assertion errors
When an assertion fails, casperjs stops any steps in the current suite.
This could cause issues in a test suite. For example, "withFrame"
generates some steps:

- one to switch to the given frame
- one to execute the given tests
- one to switch to the main frame.

If tests fail, the third step is not executed, and then next tests fail
because they are not executed in the main frame.

we can saw this issue in selftests: if a test fails in tests/suites/casper/frame.js,
tests in tests/suites/casper/global.js fail too.
Refs #482: fixes issue with popup opened by a _blank link
With SlimerJS, checkStep turns into an infinite loop when
clicking on an <a target="_blank"> links, because navigationRequested
is staying always at true. In fact, it should not be modify
to true. In this case, onNavigationRequested is called with
isMainFrame=true instead of false. This is an issue
of SlimerJS, that needs a patch on Gecko.
laurentj/slimerjs#48

This is a "bypass" patch, and should be removed when
SlimerJS will be released with its own patched Gecko.

laurentj added some commits Jun 27, 2013

Refs #482: fixes issues in the module utils
- Type of window is "window", not "domwindow" in Gecko
- The name of an exception for a syntax error is "SyntaxError"  in gecko
- fixes utils.mergeObjects: it seems that the object constructor is undefined
  because of a bug in the security layer of sandboxes or a bug in slimerjs?
  Didn't really found the origin of this issue.
Refs #482: element.innerText is not supported by Gecko
This property on DOM element is not part of the standard of DOM.
Refs #482: Changes http_status.js tests for Gecko
It seems that Gecko has a different behavior than Phantomjs's webkit
on some HTTP response: 102, 118 and 408.
Let's do not tests on these http code with Gecko.
Refs #482: fixes tests formfill.js on input type=file
In gecko, value of <input type=file> is only the filename. It
does not contain this c:\fakepath\ path.
Refs #482: fixes test onerror.js
Error message for a ReferenceError is not equal
between Gecko and Webkit.
Fixes http headers in casper.open
Original http headers should be set only after the
query append, not immediately after calling webpage.openUrl.
The request initialization may take time, and so customHeaders
are not send because they are erased by the original value
before the request initialization. (at least in Gecko)
Refs #482: casper.viewport should wait after repaint
Since setting the viewport forces a redraw of the
rendering, in an asynchronous manner, it should wait a bit of time.
At least SlimerJS needs this delay to redraw its window.

n1k0 added a commit that referenced this pull request Jul 13, 2013

@n1k0 n1k0 merged commit cdd039e into casperjs:master Jul 13, 2013

1 check passed

default The Travis CI build passed
Details
@n1k0

This comment has been minimized.

Show comment
Hide comment
@n1k0

n1k0 Jul 13, 2013

Member

I can't express how happy I am with the great work you achieved here. Thank you so much.

Member

n1k0 commented Jul 13, 2013

I can't express how happy I am with the great work you achieved here. Thank you so much.

@damienalexandre

This comment has been minimized.

Show comment
Hide comment
@damienalexandre

damienalexandre Jul 13, 2013

Awesome feature 👍

High five!

damienalexandre commented Jul 13, 2013

Awesome feature 👍

High five!

@nhoizey

This comment has been minimized.

Show comment
Hide comment
@nhoizey

nhoizey Jul 13, 2013

\o/

Thank you both!

nhoizey commented Jul 13, 2013

\o/

Thank you both!

@bastnic

This comment has been minimized.

Show comment
Hide comment
@bastnic

bastnic Jul 13, 2013

Contributor

So nice! Thanks @laurentj & @n1k0

Contributor

bastnic commented Jul 13, 2013

So nice! Thanks @laurentj & @n1k0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment