Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 2 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 3 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 4 | |
michael@0 | 5 | #include "TestHarness.h" |
michael@0 | 6 | #include "TestingAtoms.cpp" |
michael@0 | 7 | #include "MoreTestingAtoms.cpp" |
michael@0 | 8 | |
michael@0 | 9 | int main(int argc, char** argv) |
michael@0 | 10 | { |
michael@0 | 11 | ScopedXPCOM xpcom("TestStaticAtoms"); |
michael@0 | 12 | if (xpcom.failed()) { |
michael@0 | 13 | return 1; |
michael@0 | 14 | } |
michael@0 | 15 | |
michael@0 | 16 | TestingAtoms::AddRefAtoms(); |
michael@0 | 17 | |
michael@0 | 18 | NS_SealStaticAtomTable(); |
michael@0 | 19 | |
michael@0 | 20 | nsCOMPtr<nsIAtom> atom = do_GetAtom("foo"); |
michael@0 | 21 | if (!atom) { |
michael@0 | 22 | fail("Didn't get an atom for foo."); |
michael@0 | 23 | return 1; |
michael@0 | 24 | } |
michael@0 | 25 | if (atom->IsStaticAtom()) { |
michael@0 | 26 | passed("foo is a static atom"); |
michael@0 | 27 | } else { |
michael@0 | 28 | fail("foo is not a static atom."); |
michael@0 | 29 | return 1; |
michael@0 | 30 | } |
michael@0 | 31 | if (atom == TestingAtoms::foo) { |
michael@0 | 32 | passed("foo is the right pointer"); |
michael@0 | 33 | } else { |
michael@0 | 34 | fail("foo was not the right pointer"); |
michael@0 | 35 | return 1; |
michael@0 | 36 | } |
michael@0 | 37 | nsIAtom* staticAtom = NS_GetStaticAtom(NS_LITERAL_STRING("foo")); |
michael@0 | 38 | if (!staticAtom) { |
michael@0 | 39 | fail("Did not get a static atom for foo"); |
michael@0 | 40 | return 1; |
michael@0 | 41 | } |
michael@0 | 42 | |
michael@0 | 43 | if (atom == staticAtom) { |
michael@0 | 44 | passed("do_GetAtom and NS_GetStaticAtom returned the same atom."); |
michael@0 | 45 | } else { |
michael@0 | 46 | fail("do_GetAtom and NS_GetStaticAtom returned different atoms."); |
michael@0 | 47 | return 1; |
michael@0 | 48 | } |
michael@0 | 49 | |
michael@0 | 50 | MoreTestingAtoms::AddRefAtoms(); |
michael@0 | 51 | |
michael@0 | 52 | atom = do_GetAtom("qux"); |
michael@0 | 53 | if (!atom) { |
michael@0 | 54 | fail("Didn't get an atom for qux."); |
michael@0 | 55 | return 1; |
michael@0 | 56 | } |
michael@0 | 57 | if (atom->IsStaticAtom()) { |
michael@0 | 58 | passed("qux is a static atom"); |
michael@0 | 59 | } else { |
michael@0 | 60 | fail("qux is not a static atom."); |
michael@0 | 61 | return 1; |
michael@0 | 62 | } |
michael@0 | 63 | if (atom == MoreTestingAtoms::qux) { |
michael@0 | 64 | passed("qux is the right pointer"); |
michael@0 | 65 | } else { |
michael@0 | 66 | fail("qux was not the right pointer"); |
michael@0 | 67 | return 1; |
michael@0 | 68 | } |
michael@0 | 69 | staticAtom = NS_GetStaticAtom(NS_LITERAL_STRING("qux")); |
michael@0 | 70 | if (staticAtom) { |
michael@0 | 71 | fail("Got an atom for qux. The static atom table was not sealed properly."); |
michael@0 | 72 | return 1; |
michael@0 | 73 | } |
michael@0 | 74 | return 0; |
michael@0 | 75 | } |