summaryrefslogtreecommitdiffstats
path: root/devtools/client/debugger/test/mochitest/browser_dbg_sources-iframe-reload.js
blob: 63c53fba50764105c824dcd9050a56d80a00a7cb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* vim: set ft=javascript ts=2 et sw=2 tw=80: */
/* Any copyright is dedicated to the Public Domain.
 * http://creativecommons.org/publicdomain/zero/1.0/ */

/**
 * Make sure iframe scripts don't disappear after few reloads (bug 1259743)
 */

"use strict";

const IFRAME_URL = "data:text/html;charset=utf-8," +
  "<script>function fn() { console.log('hello'); }</script>" +
  "<div onclick='fn()'>hello</div>";
const TAB_URL = `data:text/html;charset=utf-8,<iframe src="${IFRAME_URL}"/>`;

add_task(function* () {
  let [,, panel] = yield initDebugger();
  let dbg = panel.panelWin;
  let newSource;

  newSource = waitForDebuggerEvents(panel, dbg.EVENTS.NEW_SOURCE);
  reload(panel, TAB_URL);
  yield newSource;
  ok(true, "Source event fired on initial load");

  for (let i = 0; i < 5; i++) {
    newSource = waitForDebuggerEvents(panel, dbg.EVENTS.NEW_SOURCE);
    reload(panel);
    yield newSource;
    ok(true, `Source event fired after ${i + 1} reloads`);
  }

  yield closeDebuggerAndFinish(panel);
});