Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / http / tests / css / resources / referrer-check.php
1 <?php
2
3 function getReferrerPath() {
4     if (!isset($_SERVER["HTTP_REFERER"]))
5         return "";
6     $url = parse_url($_SERVER["HTTP_REFERER"]);
7     return $url['path'];
8 }
9
10 function putImage() {
11     $image = "../../resources/square100.png";
12     header("Content-Type: image/png");
13     header("Content-Length: " . filesize($image));
14     header("Access-Control-Allow-Origin: *");
15     ob_clean();
16     flush();
17     readfile($image);
18 }
19
20 function putFont() {
21     $font = "../../../../resources/Ahem.ttf";
22     header("Content-Type: font/truetype");
23     header("Content-Length: " . filesize($font));
24     header("Access-Control-Allow-Origin: *");
25     ob_clean();
26     flush();
27     readfile($font);
28 }
29
30 $expectedReferrerPaths = array(
31     "document" => "/css/css-resources-referrer.html",
32     "sheet" => "/css/resources/css-resources-referrer.css",
33     "importedSheet" => "/css/resources/css-resources-referrer-import.css",
34     "iframe" => "/from/iframe.html"
35 );
36
37 $from = $_GET["from"];
38 $resource = $_GET["resource"];
39 $referrerPath = getReferrerPath();
40
41 if ($referrerPath === $expectedReferrerPaths[$from]) {
42     if ($resource === "image" || $resource === "image2")
43         putImage();
44     else if ($resource === "font")
45         putFont();
46     else
47         header("HTTP/1.1 500 Internal Server Error");
48 } else {
49     header("HTTP/1.1 500 Internal Server Error");
50 }
51
52 ?>