test_webbrowser.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <?php
  2. require_once('../phpQuery/phpQuery.php');
  3. phpQuery::$debug = true;
  4. phpQuery::extend('WebBrowser');
  5. phpQuery::$ajaxAllowedHosts[] = 'gmail.com';
  6. phpQuery::$ajaxAllowedHosts[] = 'google.com';
  7. phpQuery::$ajaxAllowedHosts[] = 'www.google.com';
  8. phpQuery::$ajaxAllowedHosts[] = 'www.google.pl';
  9. phpQuery::$ajaxAllowedHosts[] = 'mail.google.com';
  10. // Google search results
  11. if (0) {
  12. phpQuery::$plugins->browserGet('http://google.com/', 'success1');
  13. /**
  14. *
  15. * @param $pq phpQueryObject
  16. * @return unknown_type
  17. */
  18. function success1($pq) {
  19. print 'success1 callback';
  20. $pq
  21. ->WebBrowser('success2')
  22. ->find('input[name=q]')
  23. ->val('phpQuery')
  24. ->parents('form')
  25. ->submit()
  26. ;
  27. }
  28. /**
  29. *
  30. * @param $html phpQueryObject
  31. * @return unknown_type
  32. */
  33. function success2($pq) {
  34. print 'success2 callback';
  35. print $pq
  36. ->find('script')->remove()->end();
  37. }
  38. }
  39. // Gmail login (not working...)
  40. if (0) {
  41. phpQuery::plugin("Scripts");
  42. phpQuery::newDocument('<div/>')
  43. ->script('google_login')
  44. ->location('http://mail.google.com/')
  45. ->toReference($pq);
  46. if ($pq) {
  47. print $pq->script('print_websafe');
  48. }
  49. }
  50. // Gmail login v2 (not working...)
  51. if (0) {
  52. $browser = null;
  53. $browserCallback = new CallbackReference($browser);
  54. phpQuery::browserGet('http://mail.google.com/', $browserCallback);
  55. if ($browser) {
  56. $browser
  57. ->WebBrowser($browserCallback)
  58. ->find('#Email')
  59. ->val('XXX@gmail.com')->end()
  60. ->find('#Passwd')
  61. ->val('XXX')
  62. ->parents('form')
  63. ->submit();
  64. if ($browser) {
  65. print $browser->script('print_websafe');
  66. }
  67. }
  68. }
  69. // if ( $result->whois() == $testResult )
  70. // print "Test '$testName' PASSED :)";
  71. // else {
  72. // print "Test '$testName' <strong>FAILED</strong> !!! ";
  73. // print "<pre>";
  74. // print_r($result->whois());
  75. // print "</pre>\n";
  76. // }
  77. // print "\n";
  78. ?>