Bug 996061 - part 0 - make tests use [scriptable] interfaces; r=ted
authorNathan Froyd <froydnj@mozilla.com>
Mon, 19 May 2014 12:35:21 -0400
changeset 205897 e3253a7cb5d4726cbb1a59f0a8c9fef887d438d2
parent 205896 d5b0cce4d2b5758513011e94dc845a2dd22f47de
child 205898 d9e56658ef051dc9c4d973004cf93a3ffa26434a
push id3741
push userasasaki@mozilla.com
push dateMon, 21 Jul 2014 20:25:18 +0000
treeherdermozilla-beta@4d6f46f5af68 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersted
bugs996061
milestone32.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 996061 - part 0 - make tests use [scriptable] interfaces; r=ted Smart xpt linking will keep around [scriptable] interfaces and anything those interfaces depend on. Modify the tests that deal with xpt linking so they use [scriptable] interfaces, ensuring that the tests continue to work in the face of smarter linkers.
python/mozbuild/mozpack/test/test_files.py
xpcom/typelib/xpt/tools/runtests.py
--- a/python/mozbuild/mozpack/test/test_files.py
+++ b/python/mozbuild/mozpack/test/test_files.py
@@ -642,29 +642,33 @@ class TestManifestFile(TestWithTmpDir):
 
         f.copy(self.tmppath('chrome.manifest'))
         content = open(self.tmppath('chrome.manifest')).read()
         self.assertEqual(content[:42], f.open().read(42))
         self.assertEqual(content, f.open().read())
 
 # Compiled typelib for the following IDL:
 #     interface foo;
-#     [uuid(5f70da76-519c-4858-b71e-e3c92333e2d6)]
+#     [scriptable, uuid(5f70da76-519c-4858-b71e-e3c92333e2d6)]
 #     interface bar {
 #         void bar(in foo f);
 #     };
+# We need to make this [scriptable] so it doesn't get deleted from the
+# typelib.  We don't need to make the foo interfaces below [scriptable],
+# because they will be automatically included by virtue of being an
+# argument to a method of |bar|.
 bar_xpt = GeneratedFile(
     b'\x58\x50\x43\x4F\x4D\x0A\x54\x79\x70\x65\x4C\x69\x62\x0D\x0A\x1A' +
     b'\x01\x02\x00\x02\x00\x00\x00\x7B\x00\x00\x00\x24\x00\x00\x00\x5C' +
     b'\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' +
     b'\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x5F' +
     b'\x70\xDA\x76\x51\x9C\x48\x58\xB7\x1E\xE3\xC9\x23\x33\xE2\xD6\x00' +
     b'\x00\x00\x05\x00\x00\x00\x00\x00\x00\x00\x0D\x00\x66\x6F\x6F\x00' +
     b'\x62\x61\x72\x00\x62\x61\x72\x00\x00\x00\x00\x01\x00\x00\x00\x00' +
-    b'\x09\x01\x80\x92\x00\x01\x80\x06\x00\x00\x00'
+    b'\x09\x01\x80\x92\x00\x01\x80\x06\x00\x00\x80'
 )
 
 # Compiled typelib for the following IDL:
 #     [uuid(3271bebc-927e-4bef-935e-44e0aaf3c1e5)]
 #     interface foo {
 #         void foo();
 #     };
 foo_xpt = GeneratedFile(
--- a/xpcom/typelib/xpt/tools/runtests.py
+++ b/xpcom/typelib/xpt/tools/runtests.py
@@ -383,34 +383,34 @@ class TestXPTLink(unittest.TestCase):
     def test_mergeDifferent(self):
         """
         Test that merging two typelibs with completely different interfaces
         produces the correctly merged typelib.
         
         """
         t1 = xpt.Typelib()
         # add an unresolved interface
-        t1.interfaces.append(xpt.Interface("IFoo"))
+        t1.interfaces.append(xpt.Interface("IFoo", scriptable=True))
         t2 = xpt.Typelib()
         # add an unresolved interface
-        t2.interfaces.append(xpt.Interface("IBar"))
+        t2.interfaces.append(xpt.Interface("IBar", scriptable=True))
         t3 = xpt.xpt_link([t1, t2])
         
         self.assertEqual(2, len(t3.interfaces))
         # Interfaces should wind up sorted
         self.assertEqual("IBar", t3.interfaces[0].name)
         self.assertEqual("IFoo", t3.interfaces[1].name)
 
         # Add some IID values
         t1 = xpt.Typelib()
         # add an unresolved interface
-        t1.interfaces.append(xpt.Interface("IFoo", iid="11223344-5566-7788-9900-aabbccddeeff"))
+        t1.interfaces.append(xpt.Interface("IFoo", iid="11223344-5566-7788-9900-aabbccddeeff", scriptable=True))
         t2 = xpt.Typelib()
         # add an unresolved interface
-        t2.interfaces.append(xpt.Interface("IBar", iid="44332211-6655-8877-0099-aabbccddeeff"))
+        t2.interfaces.append(xpt.Interface("IBar", iid="44332211-6655-8877-0099-aabbccddeeff", scriptable=True))
         t3 = xpt.xpt_link([t1, t2])
         
         self.assertEqual(2, len(t3.interfaces))
         # Interfaces should wind up sorted
         self.assertEqual("IFoo", t3.interfaces[0].name)
         self.assertEqual("IBar", t3.interfaces[1].name)
 
     def test_mergeConflict(self):
@@ -442,32 +442,32 @@ class TestXPTLink(unittest.TestCase):
         Test that merging a typelib with an unresolved definition of
         an interface that's also unresolved in this typelib, but one
         has a valid IID copies the IID value to the resulting typelib.
 
         """
         # Unresolved in both, but t1 has an IID value
         t1 = xpt.Typelib()
         # add an unresolved interface with a valid IID
-        t1.interfaces.append(xpt.Interface("IFoo", iid="11223344-5566-7788-9900-aabbccddeeff"))
+        t1.interfaces.append(xpt.Interface("IFoo", iid="11223344-5566-7788-9900-aabbccddeeff", scriptable=True))
         t2 = xpt.Typelib()
         # add an unresolved interface, no IID
         t2.interfaces.append(xpt.Interface("IFoo"))
         t3 = xpt.xpt_link([t1, t2])
         
         self.assertEqual(1, len(t3.interfaces))
         self.assertEqual("IFoo", t3.interfaces[0].name)
         self.assertEqual("11223344-5566-7788-9900-aabbccddeeff", t3.interfaces[0].iid)
         # Unresolved in both, but t2 has an IID value
         t1 = xpt.Typelib()
         # add an unresolved interface, no IID
         t1.interfaces.append(xpt.Interface("IFoo"))
         t2 = xpt.Typelib()
         # add an unresolved interface with a valid IID
-        t2.interfaces.append(xpt.Interface("IFoo", iid="11223344-5566-7788-9900-aabbccddeeff"))
+        t2.interfaces.append(xpt.Interface("IFoo", iid="11223344-5566-7788-9900-aabbccddeeff", scriptable=True))
         t3 = xpt.xpt_link([t1, t2])
         
         self.assertEqual(1, len(t3.interfaces))
         self.assertEqual("IFoo", t3.interfaces[0].name)
         self.assertEqual("11223344-5566-7788-9900-aabbccddeeff", t3.interfaces[0].iid)
 
     def test_mergeResolvedUnresolved(self):
         """
@@ -481,33 +481,33 @@ class TestXPTLink(unittest.TestCase):
         t1 = xpt.Typelib()
         # add an unresolved interface
         t1.interfaces.append(xpt.Interface("IFoo"))
         t2 = xpt.Typelib()
         # add a resolved interface
         p = xpt.Param(xpt.SimpleType(xpt.Type.Tags.void))
         m = xpt.Method("Bar", p)
         t2.interfaces.append(xpt.Interface("IFoo", iid="11223344-5566-7788-9900-aabbccddeeff",
-                                           methods=[m]))
+                                           methods=[m], scriptable=True))
         t3 = xpt.xpt_link([t1, t2])
         
         self.assertEqual(1, len(t3.interfaces))
         self.assertEqual("IFoo", t3.interfaces[0].name)
         self.assertEqual("11223344-5566-7788-9900-aabbccddeeff", t3.interfaces[0].iid)
         self.assert_(t3.interfaces[0].resolved)
         self.assertEqual(1, len(t3.interfaces[0].methods))
         self.assertEqual("Bar", t3.interfaces[0].methods[0].name)
 
         # t1 has a resolved interface, t2 has an unresolved version
         t1 = xpt.Typelib()
         # add a resolved interface
         p = xpt.Param(xpt.SimpleType(xpt.Type.Tags.void))
         m = xpt.Method("Bar", p)
         t1.interfaces.append(xpt.Interface("IFoo", iid="11223344-5566-7788-9900-aabbccddeeff",
-                                           methods=[m]))
+                                           methods=[m], scriptable=True))
         t2 = xpt.Typelib()
         # add an unresolved interface
         t2.interfaces.append(xpt.Interface("IFoo"))
         t3 = xpt.xpt_link([t1, t2])
         
         self.assertEqual(1, len(t3.interfaces))
         self.assertEqual("IFoo", t3.interfaces[0].name)
         self.assertEqual("11223344-5566-7788-9900-aabbccddeeff", t3.interfaces[0].iid)
@@ -525,23 +525,23 @@ class TestXPTLink(unittest.TestCase):
         # but t1 also has another interface whose parent is the unresolved
         # interface.
         t1 = xpt.Typelib()
         # add an unresolved interface
         pi = xpt.Interface("IFoo")
         t1.interfaces.append(pi)
         # add a child of the unresolved interface
         t1.interfaces.append(xpt.Interface("IChild", iid="11111111-1111-1111-1111-111111111111",
-                                           resolved=True, parent=pi))
+                                           resolved=True, parent=pi, scriptable=True))
         t2 = xpt.Typelib()
         # add a resolved interface
         p = xpt.Param(xpt.SimpleType(xpt.Type.Tags.void))
         m = xpt.Method("Bar", p)
         t2.interfaces.append(xpt.Interface("IFoo", iid="11223344-5566-7788-9900-aabbccddeeff",
-                                           methods=[m]))
+                                           methods=[m], scriptable=True))
         t3 = xpt.xpt_link([t1, t2])
         
         self.assertEqual(2, len(t3.interfaces))
         self.assertEqual("IChild", t3.interfaces[0].name)
         self.assertEqual("11111111-1111-1111-1111-111111111111", t3.interfaces[0].iid)
         self.assertEqual("IFoo", t3.interfaces[1].name)
         self.assertEqual("11223344-5566-7788-9900-aabbccddeeff", t3.interfaces[1].iid)
         self.assert_(t3.interfaces[0].resolved)
@@ -552,24 +552,24 @@ class TestXPTLink(unittest.TestCase):
         # t1 has a resolved interface, t2 has an unresolved version,
         # but t2 also has another interface whose parent is the unresolved
         # interface.
         t1 = xpt.Typelib()
         # add a resolved interface
         p = xpt.Param(xpt.SimpleType(xpt.Type.Tags.void))
         m = xpt.Method("Bar", p)
         t1.interfaces.append(xpt.Interface("IFoo", iid="11223344-5566-7788-9900-aabbccddeeff",
-                                           methods=[m]))
+                                           methods=[m], scriptable=True))
         t2 = xpt.Typelib()
         # add an unresolved interface
         pi = xpt.Interface("IFoo")
         t2.interfaces.append(pi)
         # add a child of the unresolved interface
         t2.interfaces.append(xpt.Interface("IChild", iid="11111111-1111-1111-1111-111111111111",
-                                           resolved=True, parent=pi))
+                                           resolved=True, parent=pi, scriptable=True))
         t3 = xpt.xpt_link([t1, t2])
         
         self.assertEqual(2, len(t3.interfaces))
         self.assertEqual("IChild", t3.interfaces[0].name)
         self.assertEqual("11111111-1111-1111-1111-111111111111", t3.interfaces[0].iid)
         self.assertEqual("IFoo", t3.interfaces[1].name)
         self.assertEqual("11223344-5566-7788-9900-aabbccddeeff", t3.interfaces[1].iid)
         self.assert_(t3.interfaces[0].resolved)
@@ -590,23 +590,23 @@ class TestXPTLink(unittest.TestCase):
         # add an unresolved interface
         i = xpt.Interface("IFoo")
         t1.interfaces.append(i)
         # add an interface that uses the unresolved interface
         # as a return value in a method.
         p = xpt.Param(xpt.InterfaceType(i))
         m = xpt.Method("ReturnIface", p)
         t1.interfaces.append(xpt.Interface("IRetval", iid="11111111-1111-1111-1111-111111111111",
-                                           methods=[m]))
+                                           methods=[m], scriptable=True))
         t2 = xpt.Typelib()
         # add a resolved interface
         p = xpt.Param(xpt.SimpleType(xpt.Type.Tags.void))
         m = xpt.Method("Bar", p)
         t2.interfaces.append(xpt.Interface("IFoo", iid="11223344-5566-7788-9900-aabbccddeeff",
-                                           methods=[m]))
+                                           methods=[m], scriptable=True))
         t3 = xpt.xpt_link([t1, t2])
         
         self.assertEqual(2, len(t3.interfaces))
         self.assertEqual("IRetval", t3.interfaces[0].name)
         self.assertEqual("11111111-1111-1111-1111-111111111111", t3.interfaces[0].iid)
         self.assertEqual("IFoo", t3.interfaces[1].name)
         self.assertEqual("11223344-5566-7788-9900-aabbccddeeff", t3.interfaces[1].iid)
         self.assert_(t3.interfaces[1].resolved)
@@ -619,27 +619,27 @@ class TestXPTLink(unittest.TestCase):
         # t1 has a resolved interface. t2 has an unresolved version and
         # an interface that uses the unresolved interface as a return value
         # from a method.
         t1 = xpt.Typelib()
         # add a resolved interface
         p = xpt.Param(xpt.SimpleType(xpt.Type.Tags.void))
         m = xpt.Method("Bar", p)
         t1.interfaces.append(xpt.Interface("IFoo", iid="11223344-5566-7788-9900-aabbccddeeff",
-                                           methods=[m]))
+                                           methods=[m], scriptable=True))
         t2 = xpt.Typelib()
         # add an unresolved interface
         i = xpt.Interface("IFoo")
         t2.interfaces.append(i)
         # add an interface that uses the unresolved interface
         # as a return value in a method.
         p = xpt.Param(xpt.InterfaceType(i))
         m = xpt.Method("ReturnIface", p)
         t2.interfaces.append(xpt.Interface("IRetval", iid="11111111-1111-1111-1111-111111111111",
-                                           methods=[m]))
+                                           methods=[m], scriptable=True))
         t3 = xpt.xpt_link([t1, t2])
         
         self.assertEqual(2, len(t3.interfaces))
         self.assertEqual("IRetval", t3.interfaces[0].name)
         self.assertEqual("11111111-1111-1111-1111-111111111111", t3.interfaces[0].iid)
         self.assertEqual("IFoo", t3.interfaces[1].name)
         self.assertEqual("11223344-5566-7788-9900-aabbccddeeff", t3.interfaces[1].iid)
         self.assert_(t3.interfaces[1].resolved)
@@ -663,22 +663,22 @@ class TestXPTLink(unittest.TestCase):
         i = xpt.Interface("IFoo")
         t1.interfaces.append(i)
         # add an interface that uses the unresolved interface
         # as a param value in a method.
         vp = xpt.Param(xpt.SimpleType(xpt.Type.Tags.void))
         p = xpt.Param(xpt.InterfaceType(i))
         m = xpt.Method("IfaceParam", vp, params=[p])
         t1.interfaces.append(xpt.Interface("IParam", iid="11111111-1111-1111-1111-111111111111",
-                                           methods=[m]))
+                                           methods=[m], scriptable=True))
         t2 = xpt.Typelib()
         # add a resolved interface
         m = xpt.Method("Bar", vp)
         t2.interfaces.append(xpt.Interface("IFoo", iid="11223344-5566-7788-9900-aabbccddeeff",
-                                           methods=[m]))
+                                           methods=[m], scriptable=True))
         t3 = xpt.xpt_link([t1, t2])
         
         self.assertEqual(2, len(t3.interfaces))
         self.assertEqual("IParam", t3.interfaces[0].name)
         self.assertEqual("11111111-1111-1111-1111-111111111111", t3.interfaces[0].iid)
         self.assertEqual("IFoo", t3.interfaces[1].name)
         self.assertEqual("11223344-5566-7788-9900-aabbccddeeff", t3.interfaces[1].iid)
         self.assert_(t3.interfaces[1].resolved)
@@ -690,28 +690,28 @@ class TestXPTLink(unittest.TestCase):
 
         # t1 has a resolved interface. t2 has an unresolved version
         # and an interface that uses the unresolved interface as a
         # param value in a method.
         t1 = xpt.Typelib()
         # add a resolved interface
         m = xpt.Method("Bar", vp)
         t1.interfaces.append(xpt.Interface("IFoo", iid="11223344-5566-7788-9900-aabbccddeeff",
-                                           methods=[m]))
+                                           methods=[m], scriptable=True))
         t2 = xpt.Typelib()
         # add an unresolved interface
         i = xpt.Interface("IFoo")
         t2.interfaces.append(i)
         # add an interface that uses the unresolved interface
         # as a param value in a method.
         vp = xpt.Param(xpt.SimpleType(xpt.Type.Tags.void))
         p = xpt.Param(xpt.InterfaceType(i))
         m = xpt.Method("IfaceParam", vp, params=[p])
         t2.interfaces.append(xpt.Interface("IParam", iid="11111111-1111-1111-1111-111111111111",
-                                           methods=[m]))
+                                           methods=[m], scriptable=True))
         t3 = xpt.xpt_link([t1, t2])
         
         self.assertEqual(2, len(t3.interfaces))
         self.assertEqual("IParam", t3.interfaces[0].name)
         self.assertEqual("11111111-1111-1111-1111-111111111111", t3.interfaces[0].iid)
         self.assertEqual("IFoo", t3.interfaces[1].name)
         self.assertEqual("11223344-5566-7788-9900-aabbccddeeff", t3.interfaces[1].iid)
         self.assert_(t3.interfaces[1].resolved)
@@ -738,22 +738,22 @@ class TestXPTLink(unittest.TestCase):
         t1.interfaces.append(i)
         # add an interface that uses the unresolved interface
         # as a type in an ArrayType in a param value in a method.
         vp = xpt.Param(xpt.SimpleType(xpt.Type.Tags.void))
         intp = xpt.Param(xpt.SimpleType(xpt.Type.Tags.int32))
         p = xpt.Param(xpt.ArrayType(xpt.InterfaceType(i), 1, 2))
         m = xpt.Method("ArrayIfaceParam", vp, params=[p, intp, intp])
         t1.interfaces.append(xpt.Interface("IParam", iid="11111111-1111-1111-1111-111111111111",
-                                           methods=[m]))
+                                           methods=[m], scriptable=True))
         t2 = xpt.Typelib()
         # add a resolved interface
         m = xpt.Method("Bar", vp)
         t2.interfaces.append(xpt.Interface("IFoo", iid="11223344-5566-7788-9900-aabbccddeeff",
-                                           methods=[m]))
+                                           methods=[m], scriptable=True))
         t3 = xpt.xpt_link([t1, t2])
         
         self.assertEqual(2, len(t3.interfaces))
         self.assertEqual("IParam", t3.interfaces[0].name)
         self.assertEqual("11111111-1111-1111-1111-111111111111", t3.interfaces[0].iid)
         self.assertEqual("IFoo", t3.interfaces[1].name)
         self.assertEqual("11223344-5566-7788-9900-aabbccddeeff", t3.interfaces[1].iid)
         self.assert_(t3.interfaces[1].resolved)