
806 A.2d 431 (2002)
UNIONAMERICA INSURANCE COMPANY, LTD., Appellant
v.
J.B. JOHNSON t/a J.B. Johnson Roofing Company, Inc., AllCity Insurance Agency, Inc. and Glenn A. Brown t/a 6770-78 Market Street Partnership, Appellees
Superior Court of Pennsylvania.
Argued June 27, 2002.
Filed August 27, 2002.
*432 Carl D. Buchholz, Philadelphia, for appellant.
Jeffrey H. Quinn, Philadelphia, for Brown, appellee.
Before: DEL SOLE, P.J., FORD ELLIOTT, JOYCE, STEVENS, MUSMANNO, ORIE MELVIN, LALLY-GREEN, KLEIN and BENDER, JJ.
DEL SOLE, P.J.
¶ 1 This is an appeal from the order requiring Appellant, Unionamerica Insurance Company, ("Unionamerica"), to defend and indemnify Appellee J.B. Johnson Roofing, Inc. ("Johnson Roofing") in an underlying property damage lawsuit. For the following reasons, we affirm in part and reverse in part.
¶ 2 A declaratory judgment action was brought by Unionamerica after AllCity Insurance Agency filed an action against Appellee Johnson Roofing for damages arising from the repair and replacement of the roof on property owned by Glenn A. Brown and leased to AllCity Insurance Agency. The trial court entered judgment on behalf of Appellees, finding that Appellee Johnson Roofing's insurance policy required Unionamerica to defend and indemnify them in the underlying claim brought by AllCity Insurance Agency. The court held that no exception found within the insurance policy excused Appellant's duty to defend and indemnify Appellee Johnson Roofing.
¶ 3 The court's ruling was based upon a stipulation of facts which referred to the following claims made by AllCity in the complaint it filed against Johnson Roofing.
¶ 4 Defendant Johnson was negligent by:
a. failing to properly repair/replace the roof on the Office Building;
b. leaving the roof open in inclement weather;
c. failing to properly cover the open roof;
d. failing to perform the work to the roof in a good and workmanlike manner and failed to comply with standard roofing practices and codes;
e. failing to comply with standard roofing practices and codes;
f. failing to conform to the normal and reasonable standard of care to protect the property of Plaintiff;
g. performing the work to the roof in a defective, improper and/or unworkmanlike manner;
h. disregarding and/or violating standard professional practices;
i. utilizing poor and/or defective materials and/or utilizing materials of insufficient quality and quantity;
*433 j. failing to take reasonable steps to determine any approaching adverse weather
Stipulated Facts at 4. The stipulation also notes that the policy at issue included a "Roofing Endorsement," which provided:
In consideration of the premium charged, coverage is excluded for damages due to property damage arising out of wind, hail, snow, rain, ice or any combination of these, if:
(1) The contractor has not taken prudent steps to determine any approaching adverse weather.
(2) The contractor has not provided a suitable temporary covering, able to withstand the normal elements. (This covering is to be put in place at any time the contractor leaves the job site....)
Stipulation of Facts at 3 (emphasis in original). In addition, the stipulation included the following statements regarding J.B. Johnson's deposition testimony:
16. Defendant, J.B. Johnson, stated in his deposition that he checked the weather reports prior to starting Brown's roofing job.
17. Defendant, J.B. Johnson, stated in his deposition that when he left Brown's roofing job, the roof was temporarily covered with bay sheet and fiberglass felt.
18. Defendant, J.B. Johnson, stated in his deposition that when he left the job at the end of the day, the roof was sealed in order to avoid leaks from the roof into the building.
19. Defendant, J.B. Johnson, stated in his deposition that before the rain, he sealed the roof in order to prevent the roof from leaking.
Stipulation at 6 (citations to deposition omitted).
¶ 5 Based upon the facts as stipulated, the trial court ruled that the "`Roofing Endorsement' is not activated to preclude coverage for the claim for damage filed by AllCity." The court remarked that the "Stipulated Facts establish that Johnson took steps to determine the approach of bad weather and placed a temporary covering on the roof."
¶ 6 On appeal Unionamerica contends that the court erred in its conclusion that the "Roofing Endorsement" did not exclude coverage and that it committed an error of law and/or abused its discretion in considering the deposition testimony of J.B. Johnson when making its ruling. It asserts that only the language of the insurance policy and the allegations in the underlying Complaint may be considered when determining whether a duty to defend exists. Unionamerica contends that the allegations set forth in the Complaint claim that Johnson Roofing's failure to properly cover an opening in the roof during installation resulted in property damage. It asserts that this claim is excluded under the terms of the endorsement, and that the court erred when it considered deposition testimony to negate the claim made in the Complaint.
¶ 7 Unionamerica properly notes that when a court is deciding whether a duty to defend exists, it must compare the allegations in the complaint with the provisions of the insurance contract and determine whether, if the complaint allegations are proven, the insurer would have a duty to indemnify the insured. Keystone Spray Equipment, Inc. v. Regis Insurance Company, 767 A.2d 572 (Pa.Super.2001). In the event that the complaint alleges a cause of action which may fall within the coverage of the policy, the insurer is obligated to defend. Germantown Insurance Company v. Martin, 407 Pa.Super. 326, 595 A.2d 1172 (1991). In making this determination, *434 the factual allegations of the complaint are taken to be true and the complaint is to be liberally construed with all doubts as to whether the claims may fall within the coverage of the policy to be resolved in favor of the insured. Cadwallader v. New Amsterdam Casualty Co., 396 Pa. 582, 152 A.2d 484 (1959).
¶ 8 In this case the court's ruling was based upon stipulated facts. These facts included not only the allegations made in the Complaint but also the statements made on behalf of Johnson Roofing in a deposition. Unionamerica elected to have the case proceed in this manner. Thus, the trial court considered the claims of negligence and resulting damage due to an alleged failure to cover the roof, along with Johnson Roofing's contention that the roof was properly covered. It is not disputed that, but for the exclusion, Unionamerica would have a duty to defend this action. Based upon the Stipulated Facts it is not clear whether the exclusion will apply in this case. The duty to defend remains with the insurer until it is clear that the claim has been narrowed to one beyond the terms of the policy. Britamco Underwriters, Inc. v. Weiner, 431 Pa.Super. 276, 636 A.2d 649, 652 (1991). Furthermore an insurer who disclaims its duty to defend based on a policy exclusion must bear the burden of proving the applicability of the exclusion. American States Ins. Co. v. Maryland Casualty Co., 427 Pa.Super. 170, 628 A.2d 880, 887 (1993).
¶ 9 Unionamerica chose to try this case on stipulated facts. It agreed to include in those facts statements regarding the insured's deposition testimony which disclosed its position, that the roof was covered. No facts are set forth in the Stipulated Facts to establish that the exclusion will operate in this case. At this juncture of this case, on the facts as stipulated, it cannot be determined whether the exclusion will operate. Recalling that all doubts as to whether the claims may fall within the coverage of the policy are to be resolved in favor of the insured, and that Unionamerica bears the burden of proving the applicability of an exclusion, we find no error of law or abuse of discretion in the court's ruling. Unionamerica did not firmly establish the exclusion applied; thus, the trial court was correct in determining Unionamerica had a duty to defend the underlying action.
¶ 10 The duty to defend exists until such time when it is determined that the claim is confined to a recovery that the policy does not cover. Erie Ins. Exchange v. Transamerica Ins. Co., 516 Pa. 574, 533 A.2d 1363, 1368 (1987). Facts will be further developed at trial. If, at the time of trial, facts are proven which demonstrate that the exclusion should apply, coverage will not be afforded Johnson Roofing. It is for this precise reason that we accept Unionamerica's final claim that the trial court erred in determining that Unionamerica owes a duty indemnify Johnson Roofing.
¶ 11 It was premature for the trial court to rule on the indemnity question. Initially it must be determined whether Unionamerica is liable under the terms of the policy and the facts of the case. The duty to indemnify is a conditional obligation. The duty to indemnify arises only if, after trial on the third-party claim, it is determined that the loss suffered is covered by the terms of the policy. At this stage, while the trial court properly found Unionamerica was required to defend its insured, the court improperly ruled that Unionamerica had a duty to indemnify Johnson Roofing.
¶ 12 Order affirmed in part, reversed in part. Jurisdiction relinquished.
