Line data Source code
1 : /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 : /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 : /* This Source Code Form is subject to the terms of the Mozilla Public
4 : * License, v. 2.0. If a copy of the MPL was not distributed with this
5 : * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 :
7 : #include "ScriptTrace.h"
8 :
9 : namespace mozilla {
10 : namespace dom {
11 : namespace script {
12 :
13 : static nsresult
14 15 : TestingDispatchEvent(nsIScriptElement* aScriptElement,
15 : const nsAString& aEventType)
16 : {
17 : static bool sExposeTestInterfaceEnabled = false;
18 : static bool sExposeTestInterfacePrefCached = false;
19 15 : if (!sExposeTestInterfacePrefCached) {
20 1 : sExposeTestInterfacePrefCached = true;
21 : Preferences::AddBoolVarCache(&sExposeTestInterfaceEnabled,
22 : "dom.expose_test_interfaces",
23 1 : false);
24 : }
25 15 : if (!sExposeTestInterfaceEnabled) {
26 15 : return NS_OK;
27 : }
28 :
29 0 : nsCOMPtr<nsINode> target(do_QueryInterface(aScriptElement));
30 0 : if (!target) {
31 0 : return NS_OK;
32 : }
33 :
34 : RefPtr<AsyncEventDispatcher> dispatcher =
35 0 : new AsyncEventDispatcher(target, aEventType, true, false);
36 0 : return dispatcher->PostDOMEvent();
37 : }
38 :
39 : } // script namespace
40 : } // dom namespace
41 9 : } // mozilla namespace
|