----------------------------------------------
License
----------------------------------------------
Copyright (c) 2012 Intel Corporation.

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:

* Redistributions of works must retain the original copyright notice, this list
  of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the original copyright notice,
  this list of conditions and the following disclaimer in the documentation
  and/or other materials provided with the distribution.
* Neither the name of Intel Corporation nor the names of its contributors
  may be used to endorse or promote products derived from this work without
  specific prior written permission.

THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Authors:
        Lin, Wanming <wanmingx.lin@intel.com>



----------------------------------------------
Introduction
----------------------------------------------
These tests are for checking compliance with W3C XMLHttpRequest Level 2 specification:
http://www.w3.org/TR/2012/WD-XMLHttpRequest-20121206/


----------------------------------------------
Test Environment
----------------------------------------------
1. Pre-install Testkit-Lite package.
2. Run these cases as "normal" user.


----------------------------------------------
Pre-conditions
----------------------------------------------
1. Make sure the device under testing (DUT) is connected to network.
2. Obtain the following test data and place them properly before running the cases.
   Where the ROOTDIR is refers to RPM installation root path:
   in pc ROOTDIR is "/opt/weapi-w3c-networking-tests";
   in SLP ROOTDIR is "/opt/usr/apps/org.tizen.tct-xmlhttprequest-w3c-tests/res/wgt/opt/tct-xmlhttprequest-w3c-tests/".

Note: Chromium does not support loading local files from local browser by default. If you want to load local files, you must add boot argument like 'chromium-browser --allow-file-access-from-files'.

For Test Cases: xhr2_XMLHttpRequestEventTarget_ontimeout_event.html
                xhr2_XMLHttpRequestEventTarget_onerror_event.html

Test Steps:
(Note: If you have installed Apache2+PHP and configured the virtual host, you can skip to step 4.)
   1. Install PHP:
      open terminal and type in this command: sudo apt-get install php5;
   2. Install Apache server:
      open terminal and type in this command: sudo apt-get install apache2;
   3. Configure virtual host, do the following steps:
         (1).Create /etc/apache2/sites-available/webtestingservice:
              NameVirtualHost *:8081
              Listen 8081

              <VirtualHost *:8081>
                  ServerAdmin your-mail-address
              </VirtualHost>

              Alias /opt "/var/www/opt/"
              <Directory "/var/www/opt/">
                  Options Indexes FollowSymLinks MultiViews
                  AllowOverride None
                  Order deny,allow
                  Allow from all
              </Directory>
    	 (2).Enable the /etc/apache2/sites-enable/webtestingservice in Apache2:
             $cd /etc/apache2/sites-enabled/
             $sudo ln -s /etc/apache2/sites-available/webtestingservice 001-webtestingservice
   4. Create the web project directory:
      open terminal and type in this command: mkdir -p /var/www/opt/tct-xmlhttprequest-w3c-tests/xmlhttprequest;
   5. Properly organize the web resources:
        opt/tct-xmlhttprequest-w3c-tests/xmlhttprequest/support  -->  /var/www/opt/tct-xmlhttprequest-w3c-tests/xmlhttprequest
        opt/tct-xmlhttprequest-w3c-tests/xmlhttprequest/w3c  -->  /var/www/opt/tct-xmlhttprequest-w3c-tests/xmlhttprequest
        opt/tct-xmlhttprequest-w3c-tests/resources  -->  /var/www/opt/tct-xmlhttprequest-w3c-tests
        The 11 test cases, as previously mentioned   -->   /var/www/opt/tct-xmlhttprequest-w3c-tests/xmlhttprequest
   6. Modify tct-xmlhttprequest-w3c-tests/tests.xml to change the est_script_entry node from 'http://127.0.0.1:8080' to 'http://192.168.13.28:8080'(If your server address is 192.168.13.28);
   7. Modify /var/www/opt/tct-xmlhttprequest-w3c-tests/xmlhttprequest/support/path.js file(If your virtual server address is 192.168.13.28:8081):
   var otherDomain = "http://127.0.0.1:8081"; --> var otherDomain = "http://192.168.13.28:8081";
   8. Restart Apache server:
      open terminal and type in this command: sudo /etc/init.d/apache2 restart;


----------------------------------------------
Build and Run
----------------------------------------------
(Suppose you only get the source code and Testkit-Lite has been set up on your test machine.
 If you have got tct-xmlhttprequest-w3c-tests ZIP packages, you can directly go to step 3 on the test machine;
 if you have not installed Testkit-Lite, you need to install the latest version.)

Steps:
1. Prepare for building by running the following command:
   cd tct-xmlhttprequest-w3c-tests

2. Build ZIP package by running the following command:
   ./pack.sh

3. Unzip the package on the test machine by running the following command:
   unzip -o tct-xmlhttprequest-w3c-tests-<version>.zip -d /opt/usr/media/tct

4. Install the package on the test machine by running the following command:
   /opt/usr/media/tct/opt/tct-xmlhttprequest-w3c-tests/inst.sh

5. Run test cases by running the following command on host:
   testkit-lite -f device:/opt/usr/media/tct/opt/tct-xmlhttprequest-w3c-tests/tests.xml -e "WRTLauncher" -o tct-xmlhttprequest-w3c-tests.results.xml
