# Copyright 2017 The Cobalt Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""Tests if Cobalt properly handles time expiration after preload mode."""

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

from cobalt.black_box_tests import black_box_tests
from cobalt.black_box_tests.threaded_web_server import ThreadedWebServer


class TimerAfterPreloadTest(black_box_tests.BlackBoxTestCase):
  """Set a JS timer that expires after exiting preload mode."""

  def test_timer_after_preload(self):

    with ThreadedWebServer(binding_address=self.GetBindingAddress()) as server:
      url = server.GetURL(file_name='testdata/timer_hit_after_preload.html')
      with self.CreateCobaltRunner(
          url=url, target_params=['--preload']) as runner:
        self.assertTrue(runner.IsInPreload())
        # setInterval will hit once during the .5 seconds.
        runner.PollUntilFound('#script_executed')
        runner.SendResume()
        self.assertTrue(runner.JSTestsSucceeded())
