Skip to content

Commit

Permalink
Merge branch 'v0.9'
Browse files Browse the repository at this point in the history
Conflicts:
	src/modules/webpageUtils.jsm
	test/initial-tests.js
	test/test-environment.js
  • Loading branch information
laurentj committed Aug 25, 2014
2 parents 91d45cb + a7fca15 commit 41556bd
Show file tree
Hide file tree
Showing 15 changed files with 348 additions and 101 deletions.
4 changes: 2 additions & 2 deletions docs/api/cookie.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ A cookie object is an object that have these properties:
- ``httponly``: true if the cookie should only be sent to, and can
only be modified by, an HTTP connection.
- ``secure``: true if the cookie should only be sent over a secure connection.
- ``expires``: Holds the expiration date, formated in ISO format.
- ``expires``: Holds the expiration date, formated in ISO format (for example "2014-10-23" or "2014-10-23T14:48:00").
This property should be null for cookies existing only during a session.
- ``expiry``: : Holds the expiration date, in milliseconds since the epoch.
This property should be null for cookies existing only during a session.
This property should be null or 0 for cookies existing only during a session.

.. _expires:

Expand Down
1 change: 1 addition & 0 deletions docs/api/phantom.rst
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ cookiesEnabled
Indicates if the cookie manager is enabled (true) or disabled (false). You can
modify this property to enable or disable the cookie manager.

By default, it is enabled.

.. _phantom-defaultErrorHandler:

Expand Down
91 changes: 62 additions & 29 deletions docs/api/webpage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ Note: modifying an object in the array won't modify the cookie. You should
retrieve the array, modify it, and then set the ``cookies`` property with this array.
Probably you would prefer to use the ``addCookie()`` method to modify a cookie.

If cookies are disabled, modifying this property does nothing.
If cookies are disabled, or if no page is loaded, modifying this property does nothing.

Be careful about `the inconsistent behavior of the expiry property <cookies.html#expires>`_.

Expand Down Expand Up @@ -221,14 +221,14 @@ for key codes.
focusedFrameName
-----------------------------------------

Implemented. Documentation needed.
Contains the name of the child frame that has the focus. Read only.

.. _webpage-frameContent:

frameContent
-----------------------------------------

This property contain the source code of the current frame.
This property contain the source code of `the selected frame <../manual/frames-manipulation.html>`_.
You can set this property with the source code of an HTML page
to replace the content of the current frame.

Expand All @@ -238,47 +238,60 @@ to replace the content of the current frame.
frameName
-----------------------------------------

Implemented. Documentation needed.
Contains the name of `the selected frame <../manual/frames-manipulation.html>`_.

Read only.

.. _webpage-framePlainText:

framePlainText
-----------------------------------------

Implemented. Documentation needed.
Contains the text version of the content of `the selected frame <../manual/frames-manipulation.html>`_.

Read only.


.. _webpage-frameTitle:

frameTitle
-----------------------------------------

Implemented. Documentation needed.
Contains the title of `the selected frame <../manual/frames-manipulation.html>`_.

Read only.



.. _webpage-frameUrl:

frameUrl
-----------------------------------------

Implemented. Documentation needed.

Contains the URL of `the selected frame <../manual/frames-manipulation.html>`_.

Read only.



.. _webpage-framesCount:

framesCount
-----------------------------------------

Implemented. Documentation needed.
Contains the number of child frames of `the selected frame <../manual/frames-manipulation.html>`_.

Read only.

.. _webpage-framesName:

framesName
-----------------------------------------

Implemented. Documentation needed.
Contains the list of names of child frames of `the selected frame <../manual/frames-manipulation.html>`_.

Read only.


.. _webpage-libraryPath:
Expand Down Expand Up @@ -507,7 +520,7 @@ The domain and the path of the cookie will be set to the domain
and the path of the current url.

It returns true if the cookie has been really added. If cookies are
disabled, the cookie is not added into the cookie database.
disabled, or if no page is loaded, the cookie is not added into the cookie database.

Be careful about `the inconsistent behavior of the expiry property <cookies.html#expires>`_.

Expand All @@ -517,15 +530,19 @@ Be careful about `the inconsistent behavior of the expiry property <cookies.html
childFramesCount()
-----------------------------------------

Implemented. Documentation needed.
Returns the number child frames of `the selected frame <../manual/frames-manipulation.html>`_.

Deprecated. Use :ref:`framesCount <webpage-framesCount>` instead.


.. _webpage-childFramesName:

childFramesName()
-----------------------------------------

Implemented. Documentation needed.
Returns the list of the names of child frames of `the selected frame <../manual/frames-manipulation.html>`_.

Deprecated. Use :ref:`framesName <webpage-framesName>` instead.


.. _webpage-clearCookies:
Expand All @@ -551,7 +568,9 @@ to be able to reuse the webpage object.
currentFrameName()
-----------------------------------------

Implemented. Documentation needed.
Returns the name of `the selected frame <../manual/frames-manipulation.html>`_.

Deprecated. Use :ref:`frameName <webpage-frameName>` instead.


.. _webpage-deleteCookie:
Expand All @@ -571,15 +590,20 @@ evaluateJavaScript(src)
-----------------------------------------

Evaluate the current javascript source (in a string), into the context of the
loaded web page. It returns the result of the evaluation.
loaded web page, or if a frame is selected, into the context of
`the selected frame <../manual/frames-manipulation.html>`_.
It returns the result of the evaluation.

.. _webpage-evaluate:

evaluate(func, arg1, arg2...)
-----------------------------------------

It executes the given function in the context of the loaded web page. It means
that the code of the function cannot access to objects and variables of your script.
It executes the given function in the context of the loaded web page, or if a frame is
selected, into the context of `the selected frame <../manual/frames-manipulation.html>`_.
It means that the code of the function cannot access to objects and variables of your
script.

For example, in this function, the ``document`` and ``window`` objects are belongs
to the loaded page, not to your script. In other terms, you cannot use closures.

Expand Down Expand Up @@ -668,7 +692,8 @@ includeJs(url, callback)
-----------------------------------------

It loads into the current web page, the javascript file stored
at the given url.
at the given url. If `a frame is selected <../manual/frames-manipulation.html>`_,
the file is loaded into this frame.

When the load is done, the given callback is called.

Expand All @@ -678,8 +703,8 @@ injectJs(filename)
-----------------------------------------

It loads and executes the given javascript file into
the context of the current script. So the loaded script
has access to all variable of the current module.
the context of the current web page. If `a frame is selected <../manual/frames-manipulation.html>`_,
the file is executed into this frame.

If the given filename is a relative path, SlimerJS tries
to resolve the full path from the current working directory
Expand All @@ -688,7 +713,7 @@ If the file is not found, SlimerJS tries to resolve with
the libraryPath.

Note: there is a limitation in SlimerJS. If the loaded script
wants to modify a variable of the current script/module, it should
wants to modify a variable of the current web page/frame, it should
call ``window.myvariable = '..'`` instead of ``myvariable = '..'``.

.. _webpage-open:
Expand Down Expand Up @@ -990,38 +1015,46 @@ It stops the loading of the page.
switchToFocusedFrame()
-----------------------------------------

Implemented. Documentation needed.
It selects the frame that has the focus.

See `frames manipulation <../manual/frames-manipulation.html>`_.

.. _webpage-switchToFrame:

switchToFrame()
switchToFrame(name)
-----------------------------------------

Implemented. Documentation needed.
It selects the frame that has the given name, and is the child of
the current frame.

See `frames manipulation <../manual/frames-manipulation.html>`_.

.. _webpage-switchToChildFrame:

switchToChildFrame()
-----------------------------------------
Implemented. Documentation needed.

Deprecated. Use :ref:`webpage.switchToFrame() <webpage-switchToFrame>` instead.


.. _webpage-switchToMainFrame:

switchToMainFrame()
-----------------------------------------

Implemented. Documentation needed.
It selects the main frame, i.e. the root window.

See `frames manipulation <../manual/frames-manipulation.html>`_.


.. _webpage-switchToParentFrame:

switchToParentFrame()
-----------------------------------------

Implemented. Documentation needed.
It selects the parent frame of the current frame.

See `frames manipulation <../manual/frames-manipulation.html>`_.


.. _webpage-uploadFile:
Expand All @@ -1034,9 +1067,9 @@ SlimerJs is a scriptable browser, you cannot manipulate the file picker
opened when you click on this element. ``uploadFile()`` allows you to set the
value of such elements.

Arguments are the CSS selector of the input element, and the full path of the file.
The file must exist. You can also indicate an array of path, if the input element
accepts several files.
Arguments are the CSS selector (in `the current frame <../manual/frames-manipulation.html>`_)
of the input element, and the full path of the file. The file must exist. You can also
indicate an array of path, if the input element accepts several files.

Note that a virtual file picker is opened when calling ``uploadFile()``, and
so the ``onFilePicker`` callback is called. If this callback exists and
Expand Down
1 change: 1 addition & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Manual
configuration
differences-with-phantomjs
manual/http-authentication
manual/frames-manipulation

API reference
-------------
Expand Down
83 changes: 83 additions & 0 deletions docs/manual/frames-manipulation.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@

================================
Manipulating frames with webpage
================================

A web page may have different frames, and even some frames inside frames. If you want
to do things related to a specific frame, like evaluating code, the `webpage <../api/webpage.html>`_
object have some methods to select the frame you want to work with.

These methods are:

- `webpage.switchToFocusedFrame() <../api/webpage.html#webpage-switchtofocusedframe>`_:
to select the frame that has the focus. You can retrieve its name with
`webpage.focusedFrameName <../api/webpage.html#webpage-focusedframename>`_.
- `webpage.switchToFrame(framename) <../api/webpage.html#webpage-switchtoframe>`_ (or
``webpage.switchToChildFrame()``): to select a frame (in the current frame) that has
the given name. You can retrieve the list of frame names with `framesName <../api/webpage.html#webpage-framesname>`_,
and the count with `framesCount <../api/webpage.html#webpage-framescount>`_.
- `webpage.switchToParentFrame() <../api/webpage.html#webpage-switchtoparentframe>`_: to select
the parent frame of the current frame
- `webpage.switchToMainFrame() <../api/webpage.html#webpage-switchtomainframe>`_: to return to
the main frame (i.e. the root window)

Exemple to select an frame
--------------------------

.. code-block:: html

root window:
<frameset>
<frame name="f1" src="frame1.html" />
<frame name="f2" src="frame2.html" />
</frameset>

.. code-block:: html

frame1.html:
<html>... <iframe name="f3" src="frame3.html">... </html>

.. code-block:: html

frame2.html and frame3.html:
<html>... simple web page ....</html>


To select frame2.html, you'll do:

.. code-block:: javascript
webpage.switchToFrame('f2');
If you want to select the frame3.html after that, you'll do:

.. code-block:: javascript
// first return to the parent frame
webpage.switchToParentFrame(); // or switchToMainFrame() in this example
// then select frame1.html because frame3.html is a child of it
webpage.switchToFrame('f1');
// then select frame3.html
webpage.switchToFrame('f3');
Manipulating the current frame
-------------------------------

After selecting a frame, you have some properties to retrieve the frame properties:
`webpage.frameContent <../api/webpage.html#webpage-framecontent>`_,
`webpage.frameTitle <../api/webpage.html#webpage-frametitle>`_,
`webpage.frameName <../api/webpage.html#webpage-framename>`_,
`webpage.frameUrl <../api/webpage.html#webpage-frameurl>`_,
`webpage.framePlainText <../api/webpage.html#webpage-frameplaintext>`_.


And you can evaluate javascript in the current frame with
`evaluateJavaScript() <../api/webpage.html#webpage-evaluatejavadcript>`_,
`evaluate() <../api/webpage.html#webpage-evaluate>`_,
`evaluateAsync() <../api/webpage.html#webpage-evaluateasync>`_,
`includeJs() <../api/webpage.html#webpage-includejs>`_ or
`injectJs() <../api/webpage.html#webpage-injectjs>`_


13 changes: 13 additions & 0 deletions docs/release-notes-0.9.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,19 @@
Release Notes of SlimerJS 0.9
=============================

version 0.9.3
=============

Not released yet. You can download `the preview version <http://download.slimerjs.org/nightlies/>`_

Fixed bugs
----------

* The cookie manager of SlimerJS ignored session cookies (#216)
* webpage.frameContent should use the same code as webpage.content (#218)
* Fixed a regression after fixing #198: webpage.close() was called twice.
* fix error at startup about cache, with Gecko 32 (#208)

version 0.9.2
=============

Expand Down
2 changes: 1 addition & 1 deletion src/application.ini
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ Copyright=Copyright 2012-2014 Laurent Jouanneau & Innophi

[Gecko]
MinVersion=17.0.0
MaxVersion=31.*
MaxVersion=32.*
Loading

0 comments on commit 41556bd

Please sign in to comment.