summaryrefslogtreecommitdiffstats
path: root/content/shell/webkit_test_runner.js
blob: 4159b5548a2d8801b0509917fdd64985f75ae0ae (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

var testRunner = testRunner || {};

(function() {
  native function CloseWebInspector();
  native function Display();
  native function EvaluateInWebInspector();
  native function ExecCommand();
  native function GetWorkerThreadCount();
  native function NotifyDone();
  native function SetCanOpenWindows();
  native function SetDumpAsText();
  native function SetDumpChildFramesAsText();
  native function SetPrinting();
  native function SetShouldStayOnPageAfterHandlingBeforeUnload();
  native function SetWaitUntilDone();
  native function SetXSSAuditorEnabled();
  native function ShowWebInspector();

  native function GetGlobalFlag();
  native function SetGlobalFlag();

  native function NotImplemented();

  var DefaultHandler = function(name) {
    var handler = {
      get: function(receiver, property) {
        if (property === "splice")
          return undefined;
        if (property === "__proto__")
          return {}
        if (property === "toString")
          return function() { return "[object Object]"; };
        if (property === "constructor" || property === "valueOf")
          return function() { return {}; };
        NotImplemented(name, property);
        return function() {}
      },
      getOwnPropertyNames: function() {
        return [];
      },
      getPropertyDescriptor: function(property) {
        NotImplemented(name, property);
        return undefined;
      }
    }
    return Proxy.create(handler);
  }

  var TestRunner = function() {
    Object.defineProperty(this, "display", {value: Display});
    Object.defineProperty(this, "notifyDone", {value: NotifyDone});
    Object.defineProperty(this, "dumpAsText", {value: SetDumpAsText});
    Object.defineProperty(this,
                          "dumpChildFramesAsText",
                          {value: SetDumpChildFramesAsText});
    Object.defineProperty(this,
                          "setCanOpenWindows",
                          {value: SetCanOpenWindows});
    Object.defineProperty(this, "setPrinting", {value: SetPrinting});
    Object.defineProperty(
        this,
        "setShouldStayOnPageAfterHandlingBeforeUnload",
        {value: SetShouldStayOnPageAfterHandlingBeforeUnload});
    Object.defineProperty(this,
                          "setXSSAuditorEnabled",
                          {value: SetXSSAuditorEnabled});
    Object.defineProperty(this, "waitUntilDone", {value: SetWaitUntilDone});
    Object.defineProperty(this, "showWebInspector", {value: ShowWebInspector});
    Object.defineProperty(this,
                          "closeWebInspector",
                          {value: CloseWebInspector});
    Object.defineProperty(this,
                          "evaluateInWebInspector",
                          {value: EvaluateInWebInspector});
    Object.defineProperty(this, "execCommand", {value: ExecCommand});


    Object.defineProperty(this,
                          "globalFlag",
                          {
                            get: GetGlobalFlag,
                            set: SetGlobalFlag,
                            writeable: true,
                            configurable: true,
                            enumerable: true
                          });
    Object.defineProperty(this,
                          "platformName",
                          {
                            value: "chromium",
                            writeable: true,
                            configurable: true,
                            enumerable: true
                          });
    Object.defineProperty(this,
                          "workerThreadCount",
                          {get: GetWorkerThreadCount});

    var stubs = [
        "dumpDatabaseCallbacks",
        "denyWebNotificationPermission",
        "removeAllWebNotificationPermissions",
        "simulateWebNotificationClick",
        "setIconDatabaseEnabled",
        "setScrollbarPolicy",
        "clearAllApplicationCaches",
        "clearApplicationCacheForOrigin",
        "clearBackForwardList",
        "keepWebHistory",
        "setApplicationCacheOriginQuota",
        "setCallCloseOnWebViews",
        "setMainFrameIsFirstResponder",
        "setPrivateBrowsingEnabled",
        "setUseDashboardCompatibilityMode",
        "deleteAllLocalStorage",
        "localStorageDiskUsageForOrigin",
        "originsWithLocalStorage",
        "deleteLocalStorageForOrigin",
        "observeStorageTrackerNotifications",
        "syncLocalStorage",
        "addDisallowedURL",
        "applicationCacheDiskUsageForOrigin",
        "abortModal"
    ];
    for (var idx in stubs) {
      Object.defineProperty(
          this, stubs[idx], {value: function() { return null; }});
    }
  }
  TestRunner.prototype = DefaultHandler("testRunner");
  testRunner = new TestRunner();
})();