Attachment #485584: Patch for bug #605271

View | Details | Raw Unified | Return to bug 605271
Collapse All | Expand All

(-)a/content/base/src/nsGenericElement.cpp (-1 / +30 lines)
Line     Link Here 
 Lines 2081-2097   nsGenericElement::nsDOMSlots::~nsDOMSlot Link Here 
2081
  }
2081
  }
2082
2082
2083
  if (mClassList) {
2083
  if (mClassList) {
2084
    mClassList->DropReference();
2084
    mClassList->DropReference();
2085
  }
2085
  }
2086
}
2086
}
2087
2087
2088
nsGenericElement::nsGenericElement(already_AddRefed<nsINodeInfo> aNodeInfo)
2088
nsGenericElement::nsGenericElement(already_AddRefed<nsINodeInfo> aNodeInfo)
2089
  : Element(aNodeInfo)
2089
  : Element(aNodeInfo),
2090
    mExtraInterfaceImplementor(this)
2090
{
2091
{
2091
  // Set the default scriptID to JS - but skip SetScriptTypeID as it
2092
  // Set the default scriptID to JS - but skip SetScriptTypeID as it
2092
  // does extra work we know isn't necessary here...
2093
  // does extra work we know isn't necessary here...
2093
  SetFlags(NODE_IS_ELEMENT |
2094
  SetFlags(NODE_IS_ELEMENT |
2094
           (nsIProgrammingLanguage::JAVASCRIPT << NODE_SCRIPT_TYPE_OFFSET));
2095
           (nsIProgrammingLanguage::JAVASCRIPT << NODE_SCRIPT_TYPE_OFFSET));
2095
}
2096
}
2096
2097
2097
nsGenericElement::~nsGenericElement()
2098
nsGenericElement::~nsGenericElement()
 Lines 4491-4516   NS_INTERFACE_MAP_END Link Here 
4491
NS_IMPL_CYCLE_COLLECTING_ADDREF_AMBIGUOUS(nsGenericElement, nsIContent)
4492
NS_IMPL_CYCLE_COLLECTING_ADDREF_AMBIGUOUS(nsGenericElement, nsIContent)
4492
NS_IMPL_CYCLE_COLLECTING_RELEASE_AMBIGUOUS_WITH_DESTROY(nsGenericElement,
4493
NS_IMPL_CYCLE_COLLECTING_RELEASE_AMBIGUOUS_WITH_DESTROY(nsGenericElement,
4493
                                                        nsIContent,
4494
                                                        nsIContent,
4494
                                                        nsNodeUtils::LastRelease(this))
4495
                                                        nsNodeUtils::LastRelease(this))
4495
4496
4496
nsresult
4497
nsresult
4497
nsGenericElement::PostQueryInterface(REFNSIID aIID, void** aInstancePtr)
4498
nsGenericElement::PostQueryInterface(REFNSIID aIID, void** aInstancePtr)
4498
{
4499
{
4500
  if (aIID.Equals(NS_GET_IID(nsIExtraInterfaceImplementor))) {
4501
    *aInstancePtr = &this->mExtraInterfaceImplementor;
4502
    AddRef();
4503
    return NS_OK;
4504
  }
4505
4499
  nsIDocument *document = GetOwnerDoc();
4506
  nsIDocument *document = GetOwnerDoc();
4500
  if (document) {
4507
  if (document) {
4501
    return document->BindingManager()->GetBindingImplementation(this, aIID,
4508
    return document->BindingManager()->GetBindingImplementation(this, aIID,
4502
                                                                aInstancePtr);
4509
                                                                aInstancePtr);
4503
  }
4510
  }
4504
4511
4505
  *aInstancePtr = nsnull;
4512
  *aInstancePtr = nsnull;
4506
  return NS_ERROR_NO_INTERFACE;
4513
  return NS_ERROR_NO_INTERFACE;
4507
}
4514
}
4508
4515
4516
// nsIExtraInterfaceImplementor
4517
bool
4518
nsGenericElement::nsExtraInterfaceImplementor::MightHaveExtraInterface(REFNSIID aIID)
4519
{
4520
  // Make this check a noop for trusted script.  Privileged callers can always try to
4521
  // QI an element to whatever they want.
4522
  if (nsContentUtils::IsCallerTrustedForCapability("UniversalXPConnect")) {
4523
    return true; // We might not have it, but this is just to convince XPConnect
4524
                 // to do the QI, at which point it'll discover the truth.
4525
  }
4526
4527
  nsIDocument *document = mElement->GetOwnerDoc();
4528
  if (!document)
4529
    return false;
4530
4531
  nsXBLBinding* binding = document->BindingManager()->GetBinding(mElement);
4532
  if (!binding)
4533
    return false;
4534
4535
  return binding->ImplementsInterface(aIID);
4536
}
4537
4509
//----------------------------------------------------------------------
4538
//----------------------------------------------------------------------
4510
nsresult
4539
nsresult
4511
nsGenericElement::LeaveLink(nsPresContext* aPresContext)
4540
nsGenericElement::LeaveLink(nsPresContext* aPresContext)
4512
{
4541
{
4513
  nsILinkHandler *handler = aPresContext->GetLinkHandler();
4542
  nsILinkHandler *handler = aPresContext->GetLinkHandler();
4514
  if (!handler) {
4543
  if (!handler) {
4515
    return NS_OK;
4544
    return NS_OK;
4516
  }
4545
  }
(-)a/content/base/src/nsGenericElement.h (+15 lines)
Line     Link Here 
 Lines 61-76    Link Here 
61
#include "mozFlushType.h"
61
#include "mozFlushType.h"
62
#include "nsDOMAttributeMap.h"
62
#include "nsDOMAttributeMap.h"
63
#include "nsIWeakReference.h"
63
#include "nsIWeakReference.h"
64
#include "nsCycleCollectionParticipant.h"
64
#include "nsCycleCollectionParticipant.h"
65
#include "nsIDocument.h"
65
#include "nsIDocument.h"
66
#include "nsIDOMNodeSelector.h"
66
#include "nsIDOMNodeSelector.h"
67
#include "nsIDOMXPathNSResolver.h"
67
#include "nsIDOMXPathNSResolver.h"
68
#include "nsPresContext.h"
68
#include "nsPresContext.h"
69
#include "nsIExtraInterfaceImplementor.h"
69
70
70
#ifdef MOZ_SMIL
71
#ifdef MOZ_SMIL
71
#include "nsISMILAttr.h"
72
#include "nsISMILAttr.h"
72
#endif // MOZ_SMIL
73
#endif // MOZ_SMIL
73
74
74
class nsIDOMAttr;
75
class nsIDOMAttr;
75
class nsIDOMEventListener;
76
class nsIDOMEventListener;
76
class nsIFrame;
77
class nsIFrame;
 Lines 761-777   public: Link Here 
761
  virtual nsAttrInfo GetAttrInfo(PRInt32 aNamespaceID, nsIAtom* aName) const;
762
  virtual nsAttrInfo GetAttrInfo(PRInt32 aNamespaceID, nsIAtom* aName) const;
762
763
763
  NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(nsGenericElement)
764
  NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(nsGenericElement)
764
765
765
  virtual void NodeInfoChanged(nsINodeInfo* aOldNodeInfo)
766
  virtual void NodeInfoChanged(nsINodeInfo* aOldNodeInfo)
766
  {
767
  {
767
  }
768
  }
768
769
770
  // nsIExtraInterfaceImplementor
771
  class nsExtraInterfaceImplementor : public nsIExtraInterfaceImplementor {
772
  public:
773
    nsExtraInterfaceImplementor(nsGenericElement* aElement)
774
      : mElement(aElement)
775
    {}
776
    NS_FORWARD_NSISUPPORTS(mElement->);
777
    virtual bool MightHaveExtraInterface(REFNSIID aIID);
778
  protected:
779
    nsGenericElement* mElement;
780
  };
769
protected:
781
protected:
782
783
  nsExtraInterfaceImplementor mExtraInterfaceImplementor;
784
770
  /**
785
  /**
771
   * Set attribute and (if needed) notify documentobservers and fire off
786
   * Set attribute and (if needed) notify documentobservers and fire off
772
   * mutation events.  This will send the AttributeChanged notification.
787
   * mutation events.  This will send the AttributeChanged notification.
773
   * Callers of this method are responsible for calling AttributeWillChange,
788
   * Callers of this method are responsible for calling AttributeWillChange,
774
   * since that needs to happen before the new attr value has been set, and
789
   * since that needs to happen before the new attr value has been set, and
775
   * in particular before it has been parsed.
790
   * in particular before it has been parsed.
776
   *
791
   *
777
   * @param aNamespaceID  namespace of attribute
792
   * @param aNamespaceID  namespace of attribute
(-)a/content/base/test/test_bug166235.html (+2 lines)
Line     Link Here 
 Lines 62-77   https://bugzilla.mozilla.org/show_bug.cg Link Here 
62
        data.value.QueryInterface(Components.interfaces.nsISupportsString).data,
62
        data.value.QueryInterface(Components.interfaces.nsISupportsString).data,
63
      expected,
63
      expected,
64
      mime + " value in the clipboard");
64
      mime + " value in the clipboard");
65
    return data.value;
65
    return data.value;
66
  }
66
  }
67
  function testPasteText(expected, test) {
67
  function testPasteText(expected, test) {
68
    textarea.value="";
68
    textarea.value="";
69
    textarea.focus();
69
    textarea.focus();
70
    // To QI to non-ClassInfo interfaces we must assert privileges
71
    netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
70
    textarea.QueryInterface(Components.interfaces.nsIDOMNSEditableElement)
72
    textarea.QueryInterface(Components.interfaces.nsIDOMNSEditableElement)
71
            .editor.paste(1);
73
            .editor.paste(1);
72
    is(textarea.value, expected, test + ": textarea paste");
74
    is(textarea.value, expected, test + ": textarea paste");
73
  }
75
  }
74
  function testInnerHTML(id, expected) {
76
  function testInnerHTML(id, expected) {
75
    var value = document.getElementById(id).innerHTML;
77
    var value = document.getElementById(id).innerHTML;
76
    is(value, expected, id + ".innerHTML");
78
    is(value, expected, id + ".innerHTML");
77
  }
79
  }
(-)a/content/base/test/test_copypaste.html (+2 lines)
Line     Link Here 
 Lines 99-114   function testCopyPaste () { Link Here 
99
        data.value.QueryInterface(Components.interfaces.nsISupportsString).data,
99
        data.value.QueryInterface(Components.interfaces.nsISupportsString).data,
100
      expected,
100
      expected,
101
      mime + " value in the clipboard");
101
      mime + " value in the clipboard");
102
    return data.value;
102
    return data.value;
103
  }
103
  }
104
  function testPasteText(expected) {
104
  function testPasteText(expected) {
105
    textarea.value="";
105
    textarea.value="";
106
    textarea.focus();
106
    textarea.focus();
107
    // To QI to non-ClassInfo interfaces we must assert privileges
108
    netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
107
    textarea.QueryInterface(Components.interfaces.nsIDOMNSEditableElement)
109
    textarea.QueryInterface(Components.interfaces.nsIDOMNSEditableElement)
108
            .editor.paste(1);
110
            .editor.paste(1);
109
    is(textarea.value, expected, "value of the textarea after the paste");
111
    is(textarea.value, expected, "value of the textarea after the paste");
110
  }
112
  }
111
  function testSelectionToString(expected) {
113
  function testSelectionToString(expected) {
112
    is(window.getSelection().toString().replace(/\r\n/g,"\n"), expected, "Selection.toString");
114
    is(window.getSelection().toString().replace(/\r\n/g,"\n"), expected, "Selection.toString");
113
  }
115
  }
114
  function testInnerHTML(id, expected) {
116
  function testInnerHTML(id, expected) {
(-)a/content/html/content/test/test_bug388558.html (-1 / +2 lines)
Line     Link Here 
 Lines 19-35   https://bugzilla.mozilla.org/show_bug.cg Link Here 
19
<pre id="test">
19
<pre id="test">
20
<script class="testbody" type="text/javascript">
20
<script class="testbody" type="text/javascript">
21
21
22
/** Test for Bug 388558 **/
22
/** Test for Bug 388558 **/
23
var inputChange = 0;
23
var inputChange = 0;
24
var textareaChange = 0;
24
var textareaChange = 0;
25
25
26
function testUserInput() {
26
function testUserInput() {
27
  netscape.security.PrivilegeManager.enablePrivilege('UniversalBrowserWrite');
27
  // To QI to non-ClassInfo interfaces we must assert privileges
28
  netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
28
  var input = document.getElementById("input");
29
  var input = document.getElementById("input");
29
  var textarea = document.getElementById("textarea");
30
  var textarea = document.getElementById("textarea");
30
31
31
  input.focus();
32
  input.focus();
32
  input.QueryInterface(Components.interfaces.nsIDOMNSEditableElement).setUserInput("foo");
33
  input.QueryInterface(Components.interfaces.nsIDOMNSEditableElement).setUserInput("foo");
33
  input.blur();
34
  input.blur();
34
  is(inputChange, 1, "Input element should have got one change event.");
35
  is(inputChange, 1, "Input element should have got one change event.");
35
36
(-)a/content/html/content/test/test_bug389797.html (-5 / +40 lines)
Line     Link Here 
 Lines 18-33   https://bugzilla.mozilla.org/show_bug.cg Link Here 
18
<pre id="test">
18
<pre id="test">
19
<script class="testbody" type="text/javascript">
19
<script class="testbody" type="text/javascript">
20
20
21
/** Test for Bug 389797 **/
21
/** Test for Bug 389797 **/
22
var allTags = [];
22
var allTags = [];
23
var classInfos = {};
23
var classInfos = {};
24
var interfaces = {};
24
var interfaces = {};
25
var interfacesNonClassinfo = {};
25
var interfacesNonClassinfo = {};
26
var interfacesNonDOM = {};
26
27
27
function getClassName(tag) {
28
function getClassName(tag) {
28
  return "HTML" + classInfos[tag] + "Element";
29
  return "HTML" + classInfos[tag] + "Element";
29
}
30
}
30
31
31
function HTML_TAG(aTagName, aImplClass) {
32
function HTML_TAG(aTagName, aImplClass) {
32
  allTags.push(aTagName);
33
  allTags.push(aTagName);
33
  classInfos[aTagName] = aImplClass;
34
  classInfos[aTagName] = aImplClass;
 Lines 36-56   function HTML_TAG(aTagName, aImplClass) Link Here 
36
      "nsIDOMNSElement",
37
      "nsIDOMNSElement",
37
      "nsIDOMEventTarget",
38
      "nsIDOMEventTarget",
38
      "nsIDOMNSEventTarget",
39
      "nsIDOMNSEventTarget",
39
      "nsIDOMNSHTMLElement",
40
      "nsIDOMNSHTMLElement",
40
      "nsIDOMElementCSSInlineStyle",
41
      "nsIDOMElementCSSInlineStyle",
41
      "nsIDOMNodeSelector" ];
42
      "nsIDOMNodeSelector" ];
42
43
43
  // Some interfaces don't appear in classinfo because other interfaces that
44
  // Some interfaces don't appear in classinfo because other interfaces that
44
  // inherit from them do.
45
  // inherit from them do.  These are visible to unprivileged script.
45
  interfacesNonClassinfo[aTagName] =
46
  interfacesNonClassinfo[aTagName] =
46
    [ "nsIDOMNode",
47
    [ "nsIDOMNode",
47
      "nsIDOMElement",
48
      "nsIDOMElement" ];
48
      "nsIDOM3EventTarget",
49
50
  // Some interfaces don't appear in classinfo at all because they are
51
  // implementation details of the underlying XPCOM objects.  These are not
52
  // visible to unpriviliged script.
53
  interfacesNonDOM[aTagName] =
54
    [ "nsIDOM3EventTarget",
49
      "nsISupportsWeakReference" ];
55
      "nsISupportsWeakReference" ];
50
56
51
  var interfaceName = "nsIDOM" + getClassName(aTagName);
57
  var interfaceName = "nsIDOM" + getClassName(aTagName);
52
  if (interfaceName in Components.interfaces) {  // no nsIDOMHTMLSpanElement
58
  if (interfaceName in Components.interfaces) {  // no nsIDOMHTMLSpanElement
53
    interfaces[aTagName].push(interfaceName);
59
    interfaces[aTagName].push(interfaceName);
54
    interfacesNonClassinfo[aTagName].push("nsIDOMHTMLElement");
60
    interfacesNonClassinfo[aTagName].push("nsIDOMHTMLElement");
55
  } else if (aTagName != "ins" && aTagName != "del") {
61
  } else if (aTagName != "ins" && aTagName != "del") {
56
    // Inherits directly from nsIDOMHTMLElement, unless it's "ins" or "del",
62
    // Inherits directly from nsIDOMHTMLElement, unless it's "ins" or "del",
 Lines 67-83   function HTML_TAG(aTagName, aImplClass) Link Here 
67
  if (arguments.length > 2) {
73
  if (arguments.length > 2) {
68
    for (var i = 0; i < arguments[2].length; ++i) {
74
    for (var i = 0; i < arguments[2].length; ++i) {
69
      interfaces[aTagName].push(arguments[2][i]);
75
      interfaces[aTagName].push(arguments[2][i]);
70
    }
76
    }
71
  }
77
  }
72
78
73
  if (arguments.length > 3) {
79
  if (arguments.length > 3) {
74
    for (i = 0; i < arguments[3].length; ++i) {
80
    for (i = 0; i < arguments[3].length; ++i) {
75
      interfacesNonClassinfo[aTagName].push(arguments[3][i]);
81
      interfacesNonDOM[aTagName].push(arguments[3][i]);
76
    }
82
    }
77
  }
83
  }
78
}
84
}
79
85
80
const objectIfaces = [
86
const objectIfaces = [
81
    "imgIDecoderObserver", "nsIRequestObserver", "nsIStreamListener",
87
    "imgIDecoderObserver", "nsIRequestObserver", "nsIStreamListener",
82
    "nsIFrameLoaderOwner", "nsIObjectLoadingContent", "nsIInterfaceRequestor",
88
    "nsIFrameLoaderOwner", "nsIObjectLoadingContent", "nsIInterfaceRequestor",
83
    "nsIChannelEventSink"
89
    "nsIChannelEventSink"
 Lines 256-273   for each (var tag in allTags) { Link Here 
256
  // Check that each node QIs to all the things we expect it to QI to
262
  // Check that each node QIs to all the things we expect it to QI to
257
  for each (var iface in interfaces[tag].concat(interfacesNonClassinfo[tag])) {
263
  for each (var iface in interfaces[tag].concat(interfacesNonClassinfo[tag])) {
258
    is(iface in Components.interfaces, true,
264
    is(iface in Components.interfaces, true,
259
       iface + " not in Components.interfaces");
265
       iface + " not in Components.interfaces");
260
    is(node instanceof Components.interfaces[iface], true,
266
    is(node instanceof Components.interfaces[iface], true,
261
       tagName(tag) + " does not QI to " + iface);
267
       tagName(tag) + " does not QI to " + iface);
262
  }
268
  }
263
269
270
  // Check that each node doesn't QI to non-DOM things 
271
  for each (var iface in interfacesNonDOM[tag]) {
272
    is(iface in Components.interfaces, true,
273
       iface + " not in Components.interfaces");
274
    is(node instanceof Components.interfaces[iface], false,
275
       tagName(tag) + " should not QI to " + iface);
276
  }
277
}
278
279
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
280
281
for each (var tag in allTags) {
282
  var node = document.createElement(tag);
283
284
  // Have to use the proto's toString(), since HTMLAnchorElement and company
285
  // override toString().
286
  var nodeString = HTMLElement.prototype.toString.apply(node);
287
288
  // Debug builds have extra info, so chop off after "Element" if it's followed
289
  // by ' ' or ']'
290
  nodeString = nodeString.replace(/Element[\] ].*/, "Element");
291
292
  // Check that each node doesn't QI to non-DOM things, except when we have privs
293
  for each (var iface in interfacesNonDOM[tag]) {
294
    is(iface in Components.interfaces, true,
295
       iface + " not in Components.interfaces");
296
    is(node instanceof Components.interfaces[iface], true,
297
       tagName(tag) + " should QI to " + iface + " from privileged script");
298
  }
299
264
  // Now see what classinfo reports
300
  // Now see what classinfo reports
265
  netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
266
  var nodeClassInfo = node.QueryInterface(Components.interfaces.nsIClassInfo);
301
  var nodeClassInfo = node.QueryInterface(Components.interfaces.nsIClassInfo);
267
  var count = {};
302
  var count = {};
268
  var classInfoInterfaces =
303
  var classInfoInterfaces =
269
    nodeClassInfo.getInterfaces(count).
304
    nodeClassInfo.getInterfaces(count).
270
    map(function(id) { return Components.interfacesByID[id].toString(); });
305
    map(function(id) { return Components.interfacesByID[id].toString(); });
271
306
272
  // Make sure that we know about all the things classinfo claims
307
  // Make sure that we know about all the things classinfo claims
273
  for each (var classInfoInterface in classInfoInterfaces) {
308
  for each (var classInfoInterface in classInfoInterfaces) {
(-)a/content/xbl/public/Makefile.in (+1 lines)
Line     Link Here 
 Lines 40-52   topsrcdir = @top_srcdir@ Link Here 
40
srcdir		= @srcdir@
40
srcdir		= @srcdir@
41
VPATH		= @srcdir@
41
VPATH		= @srcdir@
42
42
43
include $(DEPTH)/config/autoconf.mk
43
include $(DEPTH)/config/autoconf.mk
44
44
45
MODULE		= content
45
MODULE		= content
46
46
47
EXPORTS		= \
47
EXPORTS		= \
48
	nsIExtraInterfaceImplementor.h \
48
	nsIXBLService.h \
49
	nsIXBLService.h \
49
	$(NULL)
50
	$(NULL)
50
51
51
include $(topsrcdir)/config/rules.mk
52
include $(topsrcdir)/config/rules.mk
52
53
(-)a/content/xbl/public/nsIExtraInterfaceImplementor.h (+55 lines)
Line     Link Here 
Line 0    Link Here 
1
/* ***** BEGIN LICENSE BLOCK *****
2
 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
3
 *
4
 * The contents of this file are subject to the Mozilla Public License Version
5
 * 1.1 (the "License"); you may not use this file except in compliance with
6
 * the License. You may obtain a copy of the License at
7
 * http://www.mozilla.org/MPL/
8
 *
9
 * Software distributed under the License is distributed on an "AS IS" basis,
10
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11
 * for the specific language governing rights and limitations under the
12
 * License.
13
 *
14
 * The Original Code is mozilla.org code.
15
 *
16
 * The Initial Developer of the Original Code is
17
 *   Kyle Huey <me@kylehuey.com>
18
 * Portions created by the Initial Developer are Copyright (C) 2010
19
 * the Initial Developer. All Rights Reserved.
20
 *
21
 * Contributor(s):
22
 *
23
 * Alternatively, the contents of this file may be used under the terms of
24
 * either of the GNU General Public License Version 2 or later (the "GPL"),
25
 * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
26
 * in which case the provisions of the GPL or the LGPL are applicable instead
27
 * of those above. If you wish to allow use of your version of this file only
28
 * under the terms of either the GPL or the LGPL, and not to allow others to
29
 * use your version of this file under the terms of the MPL, indicate your
30
 * decision by deleting the provisions above and replace them with the notice
31
 * and other provisions required by the GPL or the LGPL. If you do not delete
32
 * the provisions above, a recipient may use your version of this file under
33
 * the terms of any one of the MPL, the GPL or the LGPL.
34
 *
35
 * ***** END LICENSE BLOCK ***** */
36
37
#ifndef nsIExtraInterfaceImplementor_h__
38
#define nsIExtraInterfaceImplementor_h__
39
40
#include "nsISupports.h"
41
42
#define NS_IEXTRAINTERFACEIMPLEMENTOR_IID      \
43
{ 0x0d7f5e4b, 0xa5ff, 0x403c, { 0x85, 0x1e, 0x43, 0xe7, 0x75, 0x90, 0x35, 0xcf } }
44
45
// This class exposes extra interfaces through the DOM without using class info.
46
class nsIExtraInterfaceImplementor : public nsISupports
47
{
48
public:
49
  NS_DECLARE_STATIC_IID_ACCESSOR(NS_IEXTRAINTERFACEIMPLEMENTOR_IID)
50
  virtual bool MightHaveExtraInterface(REFNSIID aIID) = 0;
51
};
52
53
NS_DEFINE_STATIC_IID_ACCESSOR(nsIExtraInterfaceImplementor, NS_IEXTRAINTERFACEIMPLEMENTOR_IID)
54
55
#endif // nsIExtraInterfaceImplementor_h__
(-)a/dom/base/nsDOMClassInfo.cpp (-6 / +1 lines)
Line     Link Here 
 Lines 518-540   static const char kDOMStringBundleURL[] Link Here 
518
518
519
#define NODE_SCRIPTABLE_FLAGS                                                 \
519
#define NODE_SCRIPTABLE_FLAGS                                                 \
520
 ((DOM_DEFAULT_SCRIPTABLE_FLAGS |                                             \
520
 ((DOM_DEFAULT_SCRIPTABLE_FLAGS |                                             \
521
   nsIXPCScriptable::WANT_GETPROPERTY |                                       \
521
   nsIXPCScriptable::WANT_GETPROPERTY |                                       \
522
   nsIXPCScriptable::WANT_ADDPROPERTY |                                       \
522
   nsIXPCScriptable::WANT_ADDPROPERTY |                                       \
523
   nsIXPCScriptable::WANT_SETPROPERTY) &                                      \
523
   nsIXPCScriptable::WANT_SETPROPERTY) &                                      \
524
  ~nsIXPCScriptable::USE_JSSTUB_FOR_ADDPROPERTY)
524
  ~nsIXPCScriptable::USE_JSSTUB_FOR_ADDPROPERTY)
525
525
526
// We need to let JavaScript QI elements to interfaces that are not in
527
// the classinfo since XBL can be used to dynamically implement new
528
// unknown interfaces on elements, accessibility relies on this being
529
// possible.
530
531
#define ELEMENT_SCRIPTABLE_FLAGS                                              \
526
#define ELEMENT_SCRIPTABLE_FLAGS                                              \
532
  ((NODE_SCRIPTABLE_FLAGS & ~nsIXPCScriptable::CLASSINFO_INTERFACES_ONLY) |   \
527
  (NODE_SCRIPTABLE_FLAGS |                                                    \
533
   nsIXPCScriptable::WANT_POSTCREATE |                                        \
528
   nsIXPCScriptable::WANT_POSTCREATE |                                        \
534
   nsIXPCScriptable::WANT_ENUMERATE)
529
   nsIXPCScriptable::WANT_ENUMERATE)
535
530
536
#define EXTERNAL_OBJ_SCRIPTABLE_FLAGS                                         \
531
#define EXTERNAL_OBJ_SCRIPTABLE_FLAGS                                         \
537
  ((ELEMENT_SCRIPTABLE_FLAGS &                                                \
532
  ((ELEMENT_SCRIPTABLE_FLAGS &                                                \
538
    ~nsIXPCScriptable::USE_JSSTUB_FOR_SETPROPERTY) |                          \
533
    ~nsIXPCScriptable::USE_JSSTUB_FOR_SETPROPERTY) |                          \
539
   nsIXPCScriptable::WANT_POSTCREATE |                                        \
534
   nsIXPCScriptable::WANT_POSTCREATE |                                        \
540
   nsIXPCScriptable::WANT_GETPROPERTY |                                       \
535
   nsIXPCScriptable::WANT_GETPROPERTY |                                       \
(-)a/dom/src/threads/nsDOMWorkerMacros.h (-8 lines)
Line     Link Here 
 Lines 116-135   NS_IMPL_THREADSAFE_DOM_CI_ALL_THE_REST(_ Link Here 
116
  NS_IMETHOD GetFlags(PRUint32* aFlags)                                       \
116
  NS_IMETHOD GetFlags(PRUint32* aFlags)                                       \
117
    { return _to GetFlags(aFlags); }                                          \
117
    { return _to GetFlags(aFlags); }                                          \
118
  NS_IMETHOD GetClassIDNoAlloc(nsCID* aClassIDNoAlloc)                        \
118
  NS_IMETHOD GetClassIDNoAlloc(nsCID* aClassIDNoAlloc)                        \
119
    { return _to GetClassIDNoAlloc(aClassIDNoAlloc); }
119
    { return _to GetClassIDNoAlloc(aClassIDNoAlloc); }
120
120
121
#define NS_DECL_NSICLASSINFO_GETINTERFACES                                    \
121
#define NS_DECL_NSICLASSINFO_GETINTERFACES                                    \
122
  NS_IMETHOD GetInterfaces(PRUint32* aCount, nsIID*** aArray);
122
  NS_IMETHOD GetInterfaces(PRUint32* aCount, nsIID*** aArray);
123
123
124
// Don't know why nsISupports.idl defines this out...
125
#define NS_FORWARD_NSISUPPORTS(_to)                                           \
126
  NS_IMETHOD QueryInterface(const nsIID& uuid, void** result) {               \
127
    return _to QueryInterface(uuid, result);                                  \
128
  }                                                                           \
129
  NS_IMETHOD_(nsrefcnt) AddRef(void) { return _to AddRef(); }                 \
130
  NS_IMETHOD_(nsrefcnt) Release(void) { return _to Release(); }
131
132
#define JSON_PRIMITIVE_PROPNAME                                               \
124
#define JSON_PRIMITIVE_PROPNAME                                               \
133
  "primitive"
125
  "primitive"
134
126
135
#endif /* __NSDOMWORKERMACROS_H__ */
127
#endif /* __NSDOMWORKERMACROS_H__ */
(-)a/editor/libeditor/text/tests/test_bug596333.html (+2 lines)
Line     Link Here 
 Lines 22-37   https://bugzilla.mozilla.org/show_bug.cg Link Here 
22
/** Test for Bug 596333 **/
22
/** Test for Bug 596333 **/
23
23
24
SimpleTest.waitForExplicitFinish();
24
SimpleTest.waitForExplicitFinish();
25
addLoadEvent(function() SimpleTest.executeSoon(runTest));
25
addLoadEvent(function() SimpleTest.executeSoon(runTest));
26
26
27
var gMisspeltWords;
27
var gMisspeltWords;
28
28
29
function getEditor() {
29
function getEditor() {
30
  // To QI to non-ClassInfo interfaces we must assert privileges
31
  netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
30
  var Ci = Components.interfaces;
32
  var Ci = Components.interfaces;
31
  return document.getElementById("edit")
33
  return document.getElementById("edit")
32
                 .QueryInterface(Ci.nsIDOMNSEditableElement)
34
                 .QueryInterface(Ci.nsIDOMNSEditableElement)
33
                 .editor;
35
                 .editor;
34
}
36
}
35
37
36
function getSpellCheckSelection() {
38
function getSpellCheckSelection() {
37
  var editor = getEditor();
39
  var editor = getEditor();
(-)a/editor/libeditor/text/tests/test_texteditor_keyevent_handling.html (+2 lines)
Line     Link Here 
 Lines 90-105   function runTests() Link Here 
90
       getDesciption(aPreventedOnBubbling) + "prevented on bubbling phase");
90
       getDesciption(aPreventedOnBubbling) + "prevented on bubbling phase");
91
  }
91
  }
92
92
93
  var systemGroup =
93
  var systemGroup =
94
    Components.classes["@mozilla.org/eventlistenerservice;1"].
94
    Components.classes["@mozilla.org/eventlistenerservice;1"].
95
      getService(Components.interfaces.nsIEventListenerService).
95
      getService(Components.interfaces.nsIEventListenerService).
96
      systemEventGroup;
96
      systemEventGroup;
97
  var parentElement = document.getElementById("display");
97
  var parentElement = document.getElementById("display");
98
  // To QI to non-ClassInfo interfaces we must assert privileges
99
  netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
98
  parentElement.QueryInterface(Components.interfaces.nsIDOM3EventTarget);
100
  parentElement.QueryInterface(Components.interfaces.nsIDOM3EventTarget);
99
  parentElement.addGroupedEventListener("keypress", listener, true, systemGroup);
101
  parentElement.addGroupedEventListener("keypress", listener, true, systemGroup);
100
  parentElement.addGroupedEventListener("keypress", listener, false, systemGroup);
102
  parentElement.addGroupedEventListener("keypress", listener, false, systemGroup);
101
103
102
  function doTest(aElement, aDescription, aIsSingleLine, aIsReadonly,
104
  function doTest(aElement, aDescription, aIsSingleLine, aIsReadonly,
103
                  aIsTabbable)
105
                  aIsTabbable)
104
  {
106
  {
105
    function reset(aText)
107
    function reset(aText)
(-)a/js/src/xpconnect/src/xpcwrappednative.cpp (-1 / +12 lines)
Line     Link Here 
 Lines 47-62    Link Here 
47
#include "nsWrapperCache.h"
47
#include "nsWrapperCache.h"
48
#include "xpclog.h"
48
#include "xpclog.h"
49
#include "jstl.h"
49
#include "jstl.h"
50
#include "nsINode.h"
50
#include "nsINode.h"
51
#include "xpcquickstubs.h"
51
#include "xpcquickstubs.h"
52
#include "jsproxy.h"
52
#include "jsproxy.h"
53
#include "AccessCheck.h"
53
#include "AccessCheck.h"
54
#include "WrapperFactory.h"
54
#include "WrapperFactory.h"
55
#include "nsIExtraInterfaceImplementor.h"
55
56
56
/***************************************************************************/
57
/***************************************************************************/
57
58
58
NS_IMPL_CYCLE_COLLECTION_CLASS(XPCWrappedNative)
59
NS_IMPL_CYCLE_COLLECTION_CLASS(XPCWrappedNative)
59
60
60
NS_IMETHODIMP
61
NS_IMETHODIMP
61
NS_CYCLE_COLLECTION_CLASSNAME(XPCWrappedNative)::RootAndUnlinkJSObjects(void *p)
62
NS_CYCLE_COLLECTION_CLASSNAME(XPCWrappedNative)::RootAndUnlinkJSObjects(void *p)
62
{
63
{
 Lines 1891-1906   XPCWrappedNative::FindTearOff(XPCCallCon Link Here 
1891
1892
1892
return_result:
1893
return_result:
1893
1894
1894
    if(pError)
1895
    if(pError)
1895
        *pError = rv;
1896
        *pError = rv;
1896
    return to;
1897
    return to;
1897
}
1898
}
1898
1899
1900
bool MightHaveExtraInterface(nsISupports* aSupports, const nsIID* aIID)
1901
{
1902
  nsCOMPtr<nsIExtraInterfaceImplementor> eII = do_QueryInterface(aSupports);
1903
  if (!eII)
1904
    return false;
1905
1906
  return eII->MightHaveExtraInterface(*aIID);
1907
}
1908
1899
nsresult
1909
nsresult
1900
XPCWrappedNative::InitTearOff(XPCCallContext& ccx,
1910
XPCWrappedNative::InitTearOff(XPCCallContext& ccx,
1901
                              XPCWrappedNativeTearOff* aTearOff,
1911
                              XPCWrappedNativeTearOff* aTearOff,
1902
                              XPCNativeInterface* aInterface,
1912
                              XPCNativeInterface* aInterface,
1903
                              JSBool needJSObject)
1913
                              JSBool needJSObject)
1904
{
1914
{
1905
    // This is only called while locked (during XPCWrappedNative::FindTearOff).
1915
    // This is only called while locked (during XPCWrappedNative::FindTearOff).
1906
1916
 Lines 1910-1926   XPCWrappedNative::InitTearOff(XPCCallCon Link Here 
1910
    nsISupports* identity = GetIdentityObject();
1920
    nsISupports* identity = GetIdentityObject();
1911
    nsISupports* obj;
1921
    nsISupports* obj;
1912
1922
1913
    // If the scriptable helper forbids us from reflecting additional
1923
    // If the scriptable helper forbids us from reflecting additional
1914
    // interfaces, then don't even try the QI, just fail.
1924
    // interfaces, then don't even try the QI, just fail.
1915
    if(mScriptableInfo &&
1925
    if(mScriptableInfo &&
1916
       mScriptableInfo->GetFlags().ClassInfoInterfacesOnly() &&
1926
       mScriptableInfo->GetFlags().ClassInfoInterfacesOnly() &&
1917
       !mSet->HasInterface(aInterface) &&
1927
       !mSet->HasInterface(aInterface) &&
1918
       !mSet->HasInterfaceWithAncestor(aInterface))
1928
       !mSet->HasInterfaceWithAncestor(aInterface) &&
1929
       !MightHaveExtraInterface(identity, iid))
1919
    {
1930
    {
1920
        return NS_ERROR_NO_INTERFACE;
1931
        return NS_ERROR_NO_INTERFACE;
1921
    }
1932
    }
1922
1933
1923
    // We are about to call out to unlock and other code.
1934
    // We are about to call out to unlock and other code.
1924
    // So protect our intended tearoff.
1935
    // So protect our intended tearoff.
1925
1936
1926
    aTearOff->SetReserved();
1937
    aTearOff->SetReserved();
(-)a/xpcom/base/nsISupportsBase.h (+7 lines)
Line     Link Here 
 Lines 102-112   public: Link Here 
102
   */
102
   */
103
  NS_IMETHOD_(nsrefcnt) Release(void) = 0;
103
  NS_IMETHOD_(nsrefcnt) Release(void) = 0;
104
104
105
  //@}
105
  //@}
106
};
106
};
107
107
108
NS_DEFINE_STATIC_IID_ACCESSOR(nsISupports, NS_ISUPPORTS_IID)
108
NS_DEFINE_STATIC_IID_ACCESSOR(nsISupports, NS_ISUPPORTS_IID)
109
109
110
#define NS_FORWARD_NSISUPPORTS(_to)                                           \
111
  NS_IMETHOD QueryInterface(const nsIID& uuid, void** result) {               \
112
    return _to QueryInterface(uuid, result);                                  \
113
  }                                                                           \
114
  NS_IMETHOD_(nsrefcnt) AddRef(void) { return _to AddRef(); }                 \
115
  NS_IMETHOD_(nsrefcnt) Release(void) { return _to Release(); }
116
110
/*@}*/
117
/*@}*/
111
118
112
#endif
119
#endif

Return to bug 605271