- add sources.
[platform/framework/web/crosswalk.git] / src / chrome / test / data / extensions / platform_apps / url_handlers / launching_pages / navigate.js
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 (function() {
6   var target_dir = '/extensions/platform_apps/url_handlers/common/';
7   var link = document.getElementById('link');
8   var mismatching_link = document.getElementById('mismatching_link');
9   var form  = document.getElementById('form');
10
11   if (link || mismatching_link || form) {
12     var clickEvent = document.createEvent('MouseEvents');
13     clickEvent.initMouseEvent('click', true, true, window,
14                               0, 0, 0, 0, 0, false, false,
15                               false, false, 0, null);
16     if (link) {
17       console.log("Clicking a matching link");
18       link.href = target_dir + 'target.html';
19       // This click should open the handler app (pre-installed in the browser by
20       // the CPP test before launching this) with link.href.
21       link.dispatchEvent(clickEvent);
22     }
23
24     if (mismatching_link) {
25       console.log("Clicking a mismatching link");
26       mismatching_link.href = target_dir + 'mismatching_target.html';
27       // This click should NOT open the handler app, because the URL does not
28       // match the url_handlers of the app. It should open the link in a new
29       // tab instead.
30       mismatching_link.dispatchEvent(clickEvent);
31     }
32
33     if (form) {
34       console.log("Submitting a form");
35       form.action = target_dir + 'target.html';
36       var submit_button = document.getElementById("submit_button");
37       // This click should NOT open the handler app, because form submissions
38       // using POST should not be intercepted.
39       submit_button.dispatchEvent(clickEvent);
40     }
41   } else {
42     console.log("Calling window.open()");
43     window.open(target_dir + 'target.html');
44   }
45 })();