We were previously adding the certificates on each instantiation of
NetworkAccessManager, causing memory consumption to grow unbounded.
I have also removed the Qt version check. It's unnecessary as we only
build against a fixed Qt version.
https://code.google.com/p/phantomjs/issues/detail?id=882
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
Finally. After so much work, this is finally a reality.
To launch PhantomJS in "Remote WebDriver mode":
```bash
$ phantomjs --webdriver=OPTIONAL_IP:OPTIONAL_PORT
```
Also, GhostDriver brings along support for Selenium Grid: now PhantomJS can register itself to a Selenium Grid HUB.
Just launch it in Webdriver Mode with the following extra options:
```bash
$ phantomjs --webdriver=OPTIONAL_IP:OPTIONAL_PORT --webdriver-selenium-grid-hub=http://url.to.selenium.grid.hub:port
```
http://code.google.com/p/phantomjs/issues/detail?id=49
Addresses [Issue #808](http://code.google.com/p/phantomjs/issues/detail?id=808)
* back() [method]
* canGoBack [property - boolean]
* forward() [method]
* canGoForward [property - boolean]
* reload() [method]
* stop() [method]
This is to fill a small gap we ought to deal with.
IMPORTANT: this API is asynchronous. Events
like "onLoadStarted" and "onLoadFinished" are
ideal to monitor the activity of those methods.
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
* Using the "QTimer::singleShot" bites back in the ass
* The "script" takes priority and runs before the SLOT is actually invoked
Why was I using a Timer?
Not sure anymore: it must have slipped in while I was trying to work out
all the other issues I had with QNetworkCookieJar, and I left it there.
http://code.google.com/p/phantomjs/issues/detail?id=790
Before this, only the first level of child frames had the possibility to use
the Callbacks object. Now is injected recursively in all of them.
This is an extension of coverage for [Issue #683](http://code.google.com/p/phantomjs/issues/detail?id=683).
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.
This fixes CapserJS which builds a command line like this:
phantomjs bin/bootstrap.js --casper-path=~/capserjs --cli
That works on Phantom 1.6 but not on master due to the qcommandline
port.
Fix by extending qcommandlne to take a ParameterFence flag which causes
it to treat any options after a parameter as arguments. Switch
"scriptname" to use that so the 1.6 behaviour is restored.
http://code.google.com/p/phantomjs/issues/detail?id=55
This is a patch to resolve issue i reported in ticket 773 <http://code.google.com/p/phantomjs/issues/detail?id=773>.
I did build it and run tests seems to be working fine.
I hope this helps a bit :) Also i'm sending friday hugs to everyone on the team.
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.
* url - current page url
* frameUrl - current frame url
* frameContent - current frame HTML content
* framePlainText - current frame content in Plain Text (no tags)
Fixes [Issue #758](http://code.google.com/p/phantomjs/issues/detail?id=758)
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
C4900 (Object declared as a struct is defined as a class), C4100 (A formal
parameter to a function is not referenced in the function body), and
C4189 (A variable is declared and initialized, but not used).
http://code.google.com/p/phantomjs/issues/detail?id=744
Squashed commit of the following:
commit 947ee621067258adc5af382b496868ea6da6a589
Author: Vitaliy Slobodin <vitaliy.slobodin@gmail.com>
Date: Fri Aug 17 10:34:34 2012 +0400
Format code according to http://qt-project.org/wiki/Qt_Coding_Style
commit 5aaaa5338370c77dbd7bf7026949b637da536216
Author: Vitaliy Slobodin <vitaliy.slobodin@gmail.com>
Date: Thu Aug 16 13:12:05 2012 +0400
Add breakpad support for Windows (crashdumps).
Issue: http://code.google.com/p/phantomjs/issues/detail?id=576
Previously, a static build would produce three separate files:
QtWebKit.a, libjscore.a and libwebcore.a. These seem to have
dependencies on each other and this caused the build errors on Linux.
This change means that the sources of jscore and webcore are both built
directly into the QtWebKit.a target. libjscore.a and libwebcore.a are no
longer built. It is then possible to create a static binary on Linux.
http://code.google.com/p/phantomjs/issues/detail?id=413
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
This addresses [Issue #151](http://code.google.com/p/phantomjs/issues/detail?id=151).
Summary of the new API:
- page.pages[]
- page.pagesWindowName[]
- page.getPage(windowName)
- page.windowName
- page.onPageCreated = function(newPage) { ... }
The page object created by the user holds responsibility of the "child" pages it creates.
If a page closes (i.e. window.close()) or a call to "page.pages[i].release()" is done,
the array "page.pages[]" will automatically update to contain only the pages still open.
This is still needed so that injectJs() methods work with CoffeeScript
and so that the main script file can be in CoffeeScript.
It causes duplication of code and some consideration is needed as to
how we could refactor the old inject code so that it uses modules
underneath. Lots of the module functionality written in JS could replace
the old C++ code (CSConverter, most functions in Utils).
http://code.google.com/p/phantomjs/issues/detail?id=47
Instead of using a C++ wrapper, I used a Node version of CoffeeScript
with a small JS wrapper (src/modules/_coffee-script.js). This way, since
the module system is similar enough to the Node.js module system, I only
need to require CoffeeScript in bootstrap.js and all the support for
.coffee is added by CoffeeScript itself.
To include a newer version of CoffeeScript in the source tree, see
tools/import-coffee-script.sh.
http://code.google.com/p/phantomjs/issues/detail?id=47
nativeRequire() has been refactored so that native modules are also
wrapped in Module objects. Additionally, native modules are also
cached and included in stack traces if an error occures inside them.
Phantom::loadModuleSource() has been renamed to
Phantom::readNativeModule() so that it's clear that it's used only to
load native modules.
Finally, all the require() code has been move after setting error
handlers in bootstrap.js so that if an error occurs in the require()
code, the stack trace is printed.
http://code.google.com/p/phantomjs/issues/detail?id=47
Instead of trying to use sourceId to determine what module threw an
error, we now load module's source code using modified
QWebFrame::evaluateJavaScript and leverage PhantomJS's stack traces.
http://code.google.com/p/phantomjs/issues/detail?id=47
Most of the tests passed after merging almost unchanged phantomjs-nodify
code, some needed small changes. The one that is still failing is for
CoffeeScript modules.
http://code.google.com/p/phantomjs/issues/detail?id=47
For some reason, it seems that checking CONFIG(static) inside
src/phantomjs.pro is not reliable. That caused the STATIC_BUILD define
not to be set, and hence Q_INIT_RESOURCE would never get called in
main.cpp.
Instead of using Q_INIT_RESOURCE, let's just compile the resources
directly into the phantomjs binary. This means we don't need to detect
whether Qt is linked statically or dynamically.
https://code.google.com/p/phantomjs/issues/detail?id=430
Debug mode turns off all optimisations. This make PhantomJS considerably
slower.
Instead, we build in 'release' mode, but generate debugging symbols at
the same time.
This may present some problems analysing crashes, if the optimisations
make that difficult. However, in my testing I was able to get useful
debug output even with optimisations enabled. So we should see how we go
- if it becomes a problem we can produce seperate debug binaries with no
optimisations.
https://code.google.com/p/phantomjs/issues/detail?id=599
This provides support for compiling the breakpad client into PhantomJS,
and generifies that Linux packaging scripts so that they also apply to
OS X and automate the symbol generation.
Building the Breakpad tool programs seems to be less than
straightforward on OS X, and documentation is poor. We have managed to
produce tools/dump-syms-mac.pro which allows building the dump_syms
program for dumping the debugging symbols. This needed a couple of
modifications to breakpad in order to compile successfully.
We have run out of time to work on making the minidump_stackwalk program
build. However, this is solely a developer tool and so it can wait until
after the 1.6 release before we complete this work.
Testing is welcome!
https://code.google.com/p/phantomjs/issues/detail?id=576
When console.error was called, there was a segfault because it was
treated as an uncaught exception, but did not have the correct stack
trace information (I am not sure why, but still...)
Now that we are generating the stackTrace in WebCore::reportException,
the MessageType gets set correctly, so we can use this to differentiate
between uncaught exceptions and other messages.
https://code.google.com/p/phantomjs/issues/detail?id=47
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
1. Passing JavaScript eval and other related actions to the CurrentFrame, not the MainFrame.
2. Added different methods to navigate between frames
3. With a call to "window.frames[0].focus()", the "currentFrame" changes: commands after that are sent to the new frame under focus.
4. The navigation between frames allows to walk over the "tree of frames" contained in the page.
This commit also adds examples (both in JS and CoffeeScript) and Unit Test.
http://code.google.com/p/phantomjs/issues/detail?id=573
The callback is harmless: if the user registers a "page.onCallback = [Function]",
that will receive any JS type passed via "phantomCallback()".
Also, if the handler for ".onCallback" returns a value, that is passed back as a
return value of "phantomCallback()".
Also, added "page.onConfirm" and "page.onPrompt".
This solves [Issue #133](http://code.google.com/p/phantomjs/issues/detail?id=133).
This is useful in case:
* we don't care about the result of the evaluate
* we don't need to have the result of the evaluate on the spot
* we need the stack of execution to begin WITHIN the page
Also, linting code: everyone should use a linter when writing Javascript. Everyone.
http://code.google.com/p/phantomjs/issues/detail?id=593
This removes the need to build breakpad as a separate step.
PhantomJS developers will still need to cd src/breakpad && ./configure
&& make in order to analyse crash dumps, but it is not longer necessary
in order to build PhantomJS itself.
https://code.google.com/p/phantomjs/issues/detail?id=576
This adds a new WebPage::zoomFactor property, which can be used to
zoom the page, i.e.:
page.zoomFactor = 1.5; // zoom by 50% in
page.zoomFactor = 0.5; // zoom by 50% out
The rasterize.js example is adapted to take an optional fourth argument
to set the zoom factor. Furthermore, the webpage-spec is extended with
a simple test case for the new property.
ISSUE: 579 (http://code.google.com/p/phantomjs/issues/detail?id=579)
Note that for errors that occur within subpages, this object is not the
real error object, but a copy. This is because the real object exists
within the subpage, but the page.onError handler runs within the main
context, so we have to pass it through as data.
https://code.google.com/p/phantomjs/issues/detail?id=166
Info.plist is needed to surpress the dock icon. Up to now, we need to have
the file available at run-time. With this change, the contents of
Info.plist are embedded in the executable at the linking stage, thus
there is no need to deploy the Info.plist file anymore.
Credit to Smokey Ardisson for the tip.
http://code.google.com/p/phantomjs/issues/detail?id=528
ISSUE: 460 (http://code.google.com/p/phantomjs/issues/detail?id=460)
this is a backport from qtbase:
commit 89cfe9eb01ad75c14121dbd6038b7c791226acf1
Author: Jiang Jiang <jiang.jiang@nokia.com>
Date: Thu Nov 10 18:01:56 2011 +0100
We need to reregister fonts in initializeDb because basic font db
doesn't have an internal record like fontconfig does, so just
repopulating the font database won't work. db->reregisterAppFonts
is now used properly as intended (reregister application fonts
after the system font database has been cleared).
Also, static variable 'initialized' in initializeDb() is removed
since we check privateDb()->count to see if it needs to be populated
again.
Task-number: QTBUG-22063
Change-Id: Ifc66392b56b72acbe08b99256c61421c204be5d7
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>
Usage:
page.paperSize = {
margin: "1cm",
header: {
height: "1cm",
contents: phantom.callback(function(pageNum, numPages) {
return "<h1>" + pageNum + " / " + numPages + "</h1>";
})
},
footer: {
height: "0.5cm",
contents: phantom.callback(function(pageNum, numPages) {
return "<h2>" + pageNum + " / " + numPages + "</h1>";
})
}
};
Note: The contents can return arbitrary HTML but since we cannot
re-layout the whole website for every page, the header/footers
must have the static height defined in the height property.
Note: The new example printheaderfooter.js shows the usage. It
also shows how one could delegate the above to a JavaScript
function on the loaded website, which allows one to print pages
and let the actually printed page decide how the header/footer
should look like.
Note: The page-counter can be reset by adding the class "phantomjs_reset_pagination"
to HTML block-elements that should reset the counter.
ISSUE: 410 (http://code.google.com/p/phantomjs/issues/detail?id=410)
commit c373ac4d17814588f4e3344f634ec469e56c0303
Author: Danny Wang <wangyang0123@gmail.com>
Date: Tue Apr 10 12:38:13 2012 +0800
moved i and l delarations to the top of page.evaluate()
commit bf24d4d1ecdb9e06c7bf461e87c222b10b74bc9d
Author: Danny Wang <wangyang0123@gmail.com>
Date: Tue Apr 10 08:54:55 2012 +0800
fixed defects in evaluate() pointed out by detro
commit 0bb8cff7803b70fe60fd761b1b748b5510705ee0
Author: Danny Wang <wangyang0123@gmail.com>
Date: Fri Apr 6 19:21:47 2012 +0800
added passing variables to function for page.evaluate
http://code.google.com/p/phantomjs/issues/detail?id=132
[Issue 439](http://code.google.com/p/phantomjs/issues/detail?id=439).
This works for all kind of "Content Body" but with raw bytes: the issue is that QtWebKit doesn't know how to convert a "QByteArray" to a "QVariant" (to inject it in the JavaScript space), resulting in a malformed conversion (somehow it decides to create a map where byte position is the 'key' and the byte at that position is the 'value').
This fix covers most scenarios (hopefully) but we are blocked on solving it completely.
Stop passing around lineNumber and sourceID as they are unused and don't
contain useful information.
Also declare Q_UNUSED on them to fix compiler warnings.
The hasHandler flag passed to JSC::Debugger::exception only applies to
the current stack frame. It does not indicate if there are exception
handlers in earlier stack frames.
Therefore, we are saving the frame when an exception occurs, but only
reporting the exception if it is still present once the stack has been
fully unwound.
http://code.google.com/p/phantomjs/issues/detail?id=166
add a default error handler on all pages. people can override if they
need.
ensure error handler can be removed without errors.
Hack ScriptSourceCode so we can pass in a raw string and not have it
validated as a URL
change source location hint for webpage.evaluate().
http://code.google.com/p/phantomjs/issues/detail?id=166
Please enter the commit message for your changes. Lines starting
In non-static build, JPEG is built as plugin. We force to have JPEG
support built-in by explicitly change a variable in the configure
script (unfortunately this can't be done via command-line options).
http://code.google.com/p/phantomjs/issues/detail?id=163
These classes are from the official Qt 4.8.0 platform plugins with some
tweaks:
* By default, use Fontconfig font database.
* No need to save the captured screen on every flush.
* Enlarge the screen to make it more like a typical desktop size.
http://code.google.com/p/phantomjs/issues/detail?id=163