To achieve this, Request Headers are stored in both "original" and "lowercase".
In this way we don't mangle with the request object we have received, while
still be able to handle headers when NOT in the classic "Camel-Case" format.
Fixes#11421.
For whatever reason, swapping the order with the render() tests solve the
intermittent random failures. Also, split the tests between loading
start and finish checks (to better recognize which one is failing, if
there is a failure), also make the tests more asynchoronous.
https://github.com/ariya/phantomjs/issues/11091
This feature renders PDF, GIF and other format supported by Qt to
stdout or stderr.
*NOTE*
"/dev/stdout" and "/dev/stderr" are converted to System::stdout and
System::stderr on Windows.
Issue: https://code.google.com/p/phantomjs/issues/detail?id=973
Obviously, the input must have the multiple attribute for this to work.
The API is:
page.uploadFile('#file_input', ['file1', file2'])
I haven't implemented support for multiple files in the page.filePicker
API because I couldn't work out how to get a return value of an array
of strings through the JS/C++ bridge.
https://code.google.com/p/phantomjs/issues/detail?id=256
QtWebKit normally loops infinitely trying to authenticate when it receives a
401 code, preventing all callbacks (onLoadFinished, onResourceReceived, etc).
This commit changes it to only try a set amount of times before aborting.
https://code.google.com/p/phantomjs/issues/detail?id=826
Addresses [Issue #761](http://code.google.com/p/phantomjs/issues/detail?id=761).
This is a combination of 5 commits.
1. Date in Cookie can be set via "seconds since epoch" as well.
* In addition to the current string format, we can now set cookies via integer of msec since epoch
* Expiration date can be set via "expires" or "expiry" option ("expires" has priority)
* Returned cookie will contain "expires" as string and "expiry" as msec since epoch
I believe this can simplify code that uses cookies and it doesn't change the functionality.
2. Applying the "--debug" command line options as early as possible.
3. Fixing bug and behaviour in the CookieJar
* It's not possible to set a cookie without a domain: will default to the domain of the page it's set on
* "page.clearCookies()" was broken
* "cookiejar.deleteCookie("name", url)" reimplemented because deleting via "expiration" doesn't work
4. Improving (and more fixing) in the CookieJar
* Purging Session or Expired Cookies now works
* Added boolean return values to inform if the requested cookie operation succeeded
* Timestamps for "expiry/expires" in Milliseconds, as JS does by default
* Improved detection that a cookie has been accepted or rejected by the cookiejar
NOTE: Unfortunately, the Qt provided QNetworkCookieJar is a very limited
and not extremely well designed solution. It doesn't provide any "nice
and clean" CRUD API, and you are only left with a SET/GET to deal with.
Mechanism to understand when and when not a cookie is added are hidden,
and require extra work in the sub-class (our CookieJar) to fill the gap.
5. Methods on the "phantom" object to manipulate the CookieJar.
* phantom.cookies (array of JSON/Cookies)
* phantom.cookiesEnabled (boolean)
* phantom.addCookie
* phantom.deleteCookie
* phantom.clearCookies
Those methods operate on the CookieJar directly and have no URL restriction.
In other words, if page P1 can see set of cookies C1, and page P2 can see set of
cookies C2, "phantom.cookies" can see (i.e. operate upon) both C1 and C2.
Addresses [Issue #761](http://code.google.com/p/phantomjs/issues/detail?id=761).
This is a squash of 5 commits.
1. Complete reimplementation of the CookieJar and the Cookie API - Part 1.
The save/load mechanism is inspired by the Qt Demo "browser".
More info: http://doc.qt.nokia.com/4.7-snapshot/demos-browser.html
2. Making the CookieJar a singleton.
We need to have multiple NetworkAccessManager to monitor the network activity of the page,
but we also need to maintain 1 CookieJar: in this way we now have a shared bucket of Cookies.
3. Exposing the new Cookies API to the JS space.
* Updated the completions.
* Ensured backward compatibility of the API.
* It's now possible to "phantom.cookieEnabled = false" to disable cookies completely.
* New methods: addCookie, deleteCookie, clearCookies
4. Provided some internal Doc for the new Cookies API
5. Ensuring the "page.deleteCookie(name)" method works only if a cookie name is given.
When set to "true", any page that gets created, is
owned by the "page" that control it's lifetime.
Also, the pages can be found in the "page.pages[]" array.
Default value is "true".
Addresses [Issue #151](http://code.google.com/p/phantomjs/issues/detail?id=151)
* Addresses [Issue 678](http://code.google.com/p/phantomjs/issues/detail?id=678)
* "page.close()" deprecated "page.release()"
* the callback "onClosing(page)" gets back the reference to the closing page - that can be ideal to have 1 handler for all the page that close
* It works both when closing directly the page, or if the page closes by itself
* If parent closes, child close too
Tests provided.
http://code.google.com/p/phantomjs/issues/detail?id=603
Squashed commit of the following:
commit 2087320b9549aa2bba53d73e8a681133e5b4fe96
Author: neraliu <neraliu@gmail.com>
Date: Sat Jul 14 20:55:17 2012 +0800
Improve the readability of the function CookieJar::setCookies and CookieJar::cookies.
commit 7ef076e9df488c8f82863cb9c6e31350af5eaad8
Author: neraliu <neraliu@gmail.com>
Date: Fri Jul 13 18:08:07 2012 +0800
Fix the indentation problem in the file cookiejar.cpp.
Remove some commented code segment in cookiejar.cpp.
commit d8fd7f49eb1ba0fb47c27aec9b3dcd36ca14f301
Author: neraliu <neraliu@gmail.com>
Date: Fri Jul 13 18:04:41 2012 +0800
Simplify the implementation of CookieJar::setCookiesFromUrl to use the same security policy of QNetworkCookieJar::setCookiesFromUrl in QtWebkit
commit f5e34d2b787bb9714c45a8ad0baff8b5282d3249
Author: neraliu <neraliu@gmail.com>
Date: Fri Jul 13 17:20:38 2012 +0800
Simplify the implementation of CookieJar::cookiesForUrl to use the same security policy of QNetworkCookieJar::cookiesForUrl in QtWebkit.
commit 5b10e3788cce7bd69bb71c7ee06f0b49e1e92228
Author: Nera Liu <neraliu@gmail.com>
Date: Mon Jun 25 10:56:32 2012 +0800
Remove the clearAllCookies() api by allowing to clear cookies by page.cookies = [] Javascript syntax.
commit a1f12b2913b6f3a3f11a2d22b5eb8c35bf62bf48
Author: Nera Liu <neraliu@gmail.com>
Date: Sun Jun 24 21:48:49 2012 +0800
Implement in-memory cookies storage for CookieJar allowing dynamic cookie manipulation via Javascript for issue 603.
Add sanity check for the in-memory cookies storage for CookieJar.
http://code.google.com/p/phantomjs/issues/detail?id=603
We use the Qt Meta Object system to create an easily accessible QVariantMap
representation of the Key enumerator, such that we can now write something
like for example
page.sendEvent(keypress, phantom.keys.Backspace);
http://code.google.com/p/phantomjs/issues/detail?id=492
On reflection, this approach seems like a bad idea and a source of bugs.
I think passing object references between pages seems inherently
problematic, and we are better off just passing data to the onError
handler. If users need the actual object reference, they are able to use
try ... catch within the page.
This change also means that we are no longer breaking backwards
compatibility with the page.onError function signature.
WebCore already has a bunch of plumbing to pass around stacks. This
exists for the inspector/console. However, we need to actually retrieve
the error stack in WebCore::reportException.
To achieve this, I am attaching a stackArray property to the error
object. This is not as clean as I'd like, but seems ok for now. (We
should not document stackArray though.)
https://code.google.com/p/phantomjs/issues/detail?id=166