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 | #include "base/basictypes.h" |
michael@0 | 2 | |
michael@0 | 3 | #include "TestRacyUndefer.h" |
michael@0 | 4 | |
michael@0 | 5 | #include "IPDLUnitTests.h" // fail etc. |
michael@0 | 6 | |
michael@0 | 7 | namespace mozilla { |
michael@0 | 8 | namespace _ipdltest { |
michael@0 | 9 | |
michael@0 | 10 | //----------------------------------------------------------------------------- |
michael@0 | 11 | // parent |
michael@0 | 12 | |
michael@0 | 13 | TestRacyUndeferParent::TestRacyUndeferParent() |
michael@0 | 14 | { |
michael@0 | 15 | MOZ_COUNT_CTOR(TestRacyUndeferParent); |
michael@0 | 16 | } |
michael@0 | 17 | |
michael@0 | 18 | TestRacyUndeferParent::~TestRacyUndeferParent() |
michael@0 | 19 | { |
michael@0 | 20 | MOZ_COUNT_DTOR(TestRacyUndeferParent); |
michael@0 | 21 | } |
michael@0 | 22 | |
michael@0 | 23 | void |
michael@0 | 24 | TestRacyUndeferParent::Main() |
michael@0 | 25 | { |
michael@0 | 26 | if (!SendStart()) |
michael@0 | 27 | fail("sending Start"); |
michael@0 | 28 | } |
michael@0 | 29 | |
michael@0 | 30 | bool |
michael@0 | 31 | TestRacyUndeferParent::AnswerSpam() |
michael@0 | 32 | { |
michael@0 | 33 | static bool spammed = false; |
michael@0 | 34 | static bool raced = false; |
michael@0 | 35 | if (!spammed) { |
michael@0 | 36 | spammed = true; |
michael@0 | 37 | |
michael@0 | 38 | if (!SendAwakenSpam()) |
michael@0 | 39 | fail("sending AwakenSpam"); |
michael@0 | 40 | } |
michael@0 | 41 | else if (!raced) { |
michael@0 | 42 | raced = true; |
michael@0 | 43 | |
michael@0 | 44 | if (!SendAwakenRaceWinTwice()) |
michael@0 | 45 | fail("sending WinRaceTwice"); |
michael@0 | 46 | |
michael@0 | 47 | if (!CallRace()) |
michael@0 | 48 | fail("calling Race1"); |
michael@0 | 49 | } |
michael@0 | 50 | return true; |
michael@0 | 51 | } |
michael@0 | 52 | |
michael@0 | 53 | bool |
michael@0 | 54 | TestRacyUndeferParent::AnswerRaceWinTwice() |
michael@0 | 55 | { |
michael@0 | 56 | return true; |
michael@0 | 57 | } |
michael@0 | 58 | |
michael@0 | 59 | bool |
michael@0 | 60 | TestRacyUndeferParent::RecvDone() |
michael@0 | 61 | { |
michael@0 | 62 | Close(); |
michael@0 | 63 | return true; |
michael@0 | 64 | } |
michael@0 | 65 | |
michael@0 | 66 | |
michael@0 | 67 | //----------------------------------------------------------------------------- |
michael@0 | 68 | // child |
michael@0 | 69 | |
michael@0 | 70 | TestRacyUndeferChild::TestRacyUndeferChild() |
michael@0 | 71 | { |
michael@0 | 72 | MOZ_COUNT_CTOR(TestRacyUndeferChild); |
michael@0 | 73 | } |
michael@0 | 74 | |
michael@0 | 75 | TestRacyUndeferChild::~TestRacyUndeferChild() |
michael@0 | 76 | { |
michael@0 | 77 | MOZ_COUNT_DTOR(TestRacyUndeferChild); |
michael@0 | 78 | } |
michael@0 | 79 | |
michael@0 | 80 | bool |
michael@0 | 81 | TestRacyUndeferChild::RecvStart() |
michael@0 | 82 | { |
michael@0 | 83 | if (!CallSpam()) |
michael@0 | 84 | fail("calling Spam"); |
michael@0 | 85 | |
michael@0 | 86 | if (!SendDone()) |
michael@0 | 87 | fail("sending Done"); |
michael@0 | 88 | |
michael@0 | 89 | return true; |
michael@0 | 90 | } |
michael@0 | 91 | |
michael@0 | 92 | bool |
michael@0 | 93 | TestRacyUndeferChild::RecvAwakenSpam() |
michael@0 | 94 | { |
michael@0 | 95 | if (!CallSpam()) |
michael@0 | 96 | fail("calling Spam"); |
michael@0 | 97 | return true; |
michael@0 | 98 | } |
michael@0 | 99 | |
michael@0 | 100 | bool |
michael@0 | 101 | TestRacyUndeferChild::RecvAwakenRaceWinTwice() |
michael@0 | 102 | { |
michael@0 | 103 | if (!CallRaceWinTwice()) |
michael@0 | 104 | fail("calling RaceWinTwice"); |
michael@0 | 105 | return true; |
michael@0 | 106 | } |
michael@0 | 107 | |
michael@0 | 108 | bool |
michael@0 | 109 | TestRacyUndeferChild::AnswerRace() |
michael@0 | 110 | { |
michael@0 | 111 | return true; |
michael@0 | 112 | } |
michael@0 | 113 | |
michael@0 | 114 | } // namespace _ipdltest |
michael@0 | 115 | } // namespace mozilla |