Backed out changeset c6a1177a17e4 (bug 670002) because it should have been backed out with the other patch from this bug CLOSED TREE
authorWes Kocher <wkocher@mozilla.com>
Wed, 20 Jul 2016 15:15:33 -0700
changeset 390595 0b9ec2488c89d78765add9f998661e4c7561b9e6
parent 390289 5f4846ed9f65d7622fdbd8993289daeb6b29b692
child 390596 24530e316b12694eebf9f853d6f7800f7656b579
push id23706
push users.kaspari@gmail.com
push dateThu, 21 Jul 2016 13:37:48 +0000
bugs670002
milestone50.0a1
backs outc6a1177a17e4cb0a3b0fc81a7d1e82de6d04e42a
Backed out changeset c6a1177a17e4 (bug 670002) because it should have been backed out with the other patch from this bug CLOSED TREE
devtools/client/framework/test/browser.ini
devtools/client/framework/test/browser_source-location-01.js
devtools/client/framework/test/browser_source-location-02.js
devtools/client/framework/test/browser_source_map-01.js
devtools/client/framework/test/browser_source_map-02.js
devtools/client/framework/test/code_binary_search.coffee
devtools/client/framework/test/code_binary_search.js
devtools/client/framework/test/code_binary_search.map
devtools/client/framework/test/doc_empty-tab-01.html
--- a/devtools/client/framework/test/browser.ini
+++ b/devtools/client/framework/test/browser.ini
@@ -3,22 +3,18 @@ tags = devtools
 subsuite = devtools
 support-files =
   browser_toolbox_options_disable_js.html
   browser_toolbox_options_disable_js_iframe.html
   browser_toolbox_options_disable_cache.sjs
   browser_toolbox_sidebar_tool.xul
   browser_toolbox_window_title_changes_page.html
   browser_toolbox_window_title_frame_select_page.html
-  code_binary_search.coffee
-  code_binary_search.js
-  code_binary_search.map
   code_math.js
   code_ugly.js
-  doc_empty-tab-01.html
   head.js
   shared-head.js
   shared-redux-head.js
   helper_disable_cache.js
   doc_theme.css
   doc_viewsource.html
   browser_toolbox_options_enable_serviceworkers_testing_frame_script.js
   browser_toolbox_options_enable_serviceworkers_testing.html
@@ -30,18 +26,18 @@ support-files =
 [browser_devtools_api_destroy.js]
 [browser_dynamic_tool_enabling.js]
 [browser_ignore_toolbox_network_requests.js]
 [browser_keybindings_01.js]
 [browser_keybindings_02.js]
 [browser_keybindings_03.js]
 [browser_menu_api.js]
 [browser_new_activation_workflow.js]
-[browser_source_map-01.js]
-[browser_source_map-02.js]
+[browser_source-location-01.js]
+[browser_source-location-02.js]
 [browser_target_from_url.js]
 [browser_target_events.js]
 [browser_target_remote.js]
 [browser_target_support.js]
 [browser_toolbox_custom_host.js]
 [browser_toolbox_dynamic_registration.js]
 [browser_toolbox_getpanelwhenready.js]
 [browser_toolbox_highlight.js]
rename from devtools/client/framework/test/browser_source_map-01.js
rename to devtools/client/framework/test/browser_source-location-01.js
--- a/devtools/client/framework/test/browser_source_map-01.js
+++ b/devtools/client/framework/test/browser_source-location-01.js
@@ -1,65 +1,66 @@
 /* Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/ */
+   http://creativecommons.org/publicdomain/zero/1.0/ */
 
 // Whitelisting this test.
 // As part of bug 1077403, the leaking uncaught rejections should be fixed.
 thisTestLeaksUncaughtRejectionsAndShouldBeFixed("[object Object]");
 thisTestLeaksUncaughtRejectionsAndShouldBeFixed(
   "TypeError: this.transport is null");
 
 /**
- * Tests the SourceMapService updates generated sources when source maps
+ * Tests the SourceMapController updates generated sources when source maps
  * are subsequently found. Also checks when no column is provided, and
  * when tagging an already source mapped location initially.
  */
 
 const DEBUGGER_ROOT = "http://example.com/browser/devtools/client/debugger/test/mochitest/";
 // Empty page
 const PAGE_URL = `${DEBUGGER_ROOT}doc_empty-tab-01.html`;
-const JS_URL = `${URL_ROOT}code_binary_search.js`;
-const COFFEE_URL = `${URL_ROOT}code_binary_search.coffee`;
-const { SourceMapService } = require("devtools/client/framework/source-map-service");
+const JS_URL = `${DEBUGGER_ROOT}code_binary_search.js`;
+const COFFEE_URL = `${DEBUGGER_ROOT}code_binary_search.coffee`;
+const { SourceLocationController } = require("devtools/client/framework/source-location");
 
 add_task(function* () {
-  const toolbox = yield openNewTabAndToolbox(PAGE_URL, "jsdebugger");
+  let toolbox = yield openNewTabAndToolbox(PAGE_URL, "jsdebugger");
 
-  const service = new SourceMapService(toolbox.target);
+  let controller = new SourceLocationController(toolbox.target);
 
-  const aggregator = [];
+  let aggregator = [];
 
-  function onUpdate(e, oldLoc, newLoc) {
+  function onUpdate(oldLoc, newLoc) {
     if (oldLoc.line === 6) {
       checkLoc1(oldLoc, newLoc);
     } else if (oldLoc.line === 8) {
       checkLoc2(oldLoc, newLoc);
     } else if (oldLoc.line === 2) {
       checkLoc3(oldLoc, newLoc);
     } else {
       throw new Error(`Unexpected location update: ${JSON.stringify(oldLoc)}`);
     }
     aggregator.push(newLoc);
   }
 
   let loc1 = { url: JS_URL, line: 6 };
   let loc2 = { url: JS_URL, line: 8, column: 3 };
+  let loc3 = { url: COFFEE_URL, line: 2, column: 0 };
 
-  service.subscribe(loc1, onUpdate);
-  service.subscribe(loc2, onUpdate);
+  controller.bindLocation(loc1, onUpdate);
+  controller.bindLocation(loc2, onUpdate);
+  controller.bindLocation(loc3, onUpdate);
 
   // Inject JS script
-  let sourceShown = waitForSourceShown(toolbox.getCurrentPanel(), "code_binary_search");
   yield createScript(JS_URL);
-  yield sourceShown;
 
-  yield waitUntil(() => aggregator.length === 2);
+  yield waitUntil(() => aggregator.length === 3);
 
   ok(aggregator.find(i => i.url === COFFEE_URL && i.line === 4), "found first updated location");
   ok(aggregator.find(i => i.url === COFFEE_URL && i.line === 6), "found second updated location");
+  ok(aggregator.find(i => i.url === COFFEE_URL && i.line === 2), "found third updated location");
 
   yield toolbox.destroy();
   gBrowser.removeCurrentTab();
   finish();
 });
 
 function checkLoc1(oldLoc, newLoc) {
   is(oldLoc.line, 6, "Correct line for JS:6");
@@ -74,37 +75,28 @@ function checkLoc2(oldLoc, newLoc) {
   is(oldLoc.line, 8, "Correct line for JS:8:3");
   is(oldLoc.column, 3, "Correct column for JS:8:3");
   is(oldLoc.url, JS_URL, "Correct url for JS:8:3");
   is(newLoc.line, 6, "Correct line for JS:8:3 -> COFFEE");
   is(newLoc.column, 10, "Correct column for JS:8:3 -> COFFEE");
   is(newLoc.url, COFFEE_URL, "Correct url for JS:8:3 -> COFFEE");
 }
 
+function checkLoc3(oldLoc, newLoc) {
+  is(oldLoc.line, 2, "Correct line for COFFEE:2:0");
+  is(oldLoc.column, 0, "Correct column for COFFEE:2:0");
+  is(oldLoc.url, COFFEE_URL, "Correct url for COFFEE:2:0");
+  is(newLoc.line, 2, "Correct line for COFFEE:2:0 -> COFFEE");
+  is(newLoc.column, 0, "Correct column for COFFEE:2:0 -> COFFEE");
+  is(newLoc.url, COFFEE_URL, "Correct url for COFFEE:2:0 -> COFFEE");
+}
+
 function createScript(url) {
   info(`Creating script: ${url}`);
   let mm = getFrameScript();
   let command = `
     let script = document.createElement("script");
     script.setAttribute("src", "${url}");
     document.body.appendChild(script);
     null;
   `;
   return evalInDebuggee(mm, command);
 }
-
-function waitForSourceShown(debuggerPanel, url) {
-  let { panelWin } = debuggerPanel;
-  let deferred = defer();
-
-  info(`Waiting for source ${url} to be shown in the debugger...`);
-  panelWin.on(panelWin.EVENTS.SOURCE_SHOWN, function onSourceShown(_, source) {
-
-    let sourceUrl = source.url || source.generatedUrl;
-    if (sourceUrl.includes(url)) {
-      panelWin.off(panelWin.EVENTS.SOURCE_SHOWN, onSourceShown);
-      info(`Source shown for ${url}`);
-      deferred.resolve(source);
-    }
-  });
-
-  return deferred.promise;
-}
rename from devtools/client/framework/test/browser_source_map-02.js
rename to devtools/client/framework/test/browser_source-location-02.js
--- a/devtools/client/framework/test/browser_source_map-02.js
+++ b/devtools/client/framework/test/browser_source-location-02.js
@@ -1,63 +1,63 @@
 /* vim: set ts=2 et sw=2 tw=80: */
 /* Any copyright is dedicated to the Public Domain.
- http://creativecommons.org/publicdomain/zero/1.0/ */
+   http://creativecommons.org/publicdomain/zero/1.0/ */
 
 /**
- * Tests the SourceMapService updates generated sources when pretty printing
+ * Tests the SourceLocationController updates generated sources when pretty printing
  * and un pretty printing.
  */
 
 const DEBUGGER_ROOT = "http://example.com/browser/devtools/client/debugger/test/mochitest/";
 // Empty page
 const PAGE_URL = `${DEBUGGER_ROOT}doc_empty-tab-01.html`;
 const JS_URL = `${URL_ROOT}code_ugly.js`;
-const { SourceMapService } = require("devtools/client/framework/source-map-service");
+const { SourceLocationController } = require("devtools/client/framework/source-location");
 
 add_task(function* () {
   let toolbox = yield openNewTabAndToolbox(PAGE_URL, "jsdebugger");
 
-  let service = new SourceMapService(toolbox.target);
+  let controller = new SourceLocationController(toolbox.target);
 
   let checkedPretty = false;
   let checkedUnpretty = false;
 
-  function onUpdate(e, oldLoc, newLoc) {
+  function onUpdate(oldLoc, newLoc) {
     if (oldLoc.line === 3) {
       checkPrettified(oldLoc, newLoc);
       checkedPretty = true;
     } else if (oldLoc.line === 9) {
       checkUnprettified(oldLoc, newLoc);
       checkedUnpretty = true;
     } else {
       throw new Error(`Unexpected location update: ${JSON.stringify(oldLoc)}`);
     }
   }
-  const loc1 = { url: JS_URL, line: 3 };
-  service.subscribe(loc1, onUpdate);
+
+  controller.bindLocation({ url: JS_URL, line: 3 }, onUpdate);
 
   // Inject JS script
   let sourceShown = waitForSourceShown(toolbox.getCurrentPanel(), "code_ugly.js");
   yield createScript(JS_URL);
   yield sourceShown;
 
   let ppButton = toolbox.getCurrentPanel().panelWin.document.getElementById("pretty-print");
   sourceShown = waitForSourceShown(toolbox.getCurrentPanel(), "code_ugly.js");
   ppButton.click();
   yield sourceShown;
   yield waitUntil(() => checkedPretty);
 
   // TODO check unprettified change once bug 1177446 fixed
-  // info("Testing un-pretty printing.");
-  // sourceShown = waitForSourceShown(toolbox.getCurrentPanel(), "code_ugly.js");
-  // ppButton.click();
-  // yield sourceShown;
-  // yield waitUntil(() => checkedUnpretty);
-
+  /*
+  sourceShown = waitForSourceShown(toolbox.getCurrentPanel(), "code_ugly.js");
+  ppButton.click();
+  yield sourceShown;
+  yield waitUntil(() => checkedUnpretty);
+  */
 
   yield toolbox.destroy();
   gBrowser.removeCurrentTab();
   finish();
 });
 
 function checkPrettified(oldLoc, newLoc) {
   is(oldLoc.line, 3, "Correct line for JS:3");
deleted file mode 100644
--- a/devtools/client/framework/test/code_binary_search.coffee
+++ /dev/null
@@ -1,18 +0,0 @@
-# Uses a binary search algorithm to locate a value in the specified array.
-window.binary_search = (items, value) ->
-
-  start = 0
-  stop  = items.length - 1
-  pivot = Math.floor (start + stop) / 2
-
-  while items[pivot] isnt value and start < stop
-
-    # Adjust the search area.
-    stop  = pivot - 1 if value < items[pivot]
-    start = pivot + 1 if value > items[pivot]
-
-    # Recalculate the pivot.
-    pivot = Math.floor (stop + start) / 2
-
-  # Make sure we've found the correct value.
-  if items[pivot] is value then pivot else -1
\ No newline at end of file
deleted file mode 100644
--- a/devtools/client/framework/test/code_binary_search.js
+++ /dev/null
@@ -1,29 +0,0 @@
-// Generated by CoffeeScript 1.6.1
-(function() {
-
-  window.binary_search = function(items, value) {
-    var pivot, start, stop;
-    start = 0;
-    stop = items.length - 1;
-    pivot = Math.floor((start + stop) / 2);
-    while (items[pivot] !== value && start < stop) {
-      if (value < items[pivot]) {
-        stop = pivot - 1;
-      }
-      if (value > items[pivot]) {
-        start = pivot + 1;
-      }
-      pivot = Math.floor((stop + start) / 2);
-    }
-    if (items[pivot] === value) {
-      return pivot;
-    } else {
-      return -1;
-    }
-  };
-
-}).call(this);
-
-/*
-//# sourceMappingURL=code_binary_search.map
-*/
deleted file mode 100644
--- a/devtools/client/framework/test/code_binary_search.map
+++ /dev/null
@@ -1,10 +0,0 @@
-{
-  "version": 3,
-  "file": "code_binary_search.js",
-  "sourceRoot": "",
-  "sources": [
-    "code_binary_search.coffee"
-  ],
-  "names": [],
-  "mappings": ";AACA;CAAA;CAAA,CAAA,CAAuB,EAAA,CAAjB,GAAkB,IAAxB;CAEE,OAAA,UAAA;CAAA,EAAQ,CAAR,CAAA;CAAA,EACQ,CAAR,CAAa,CAAL;CADR,EAEQ,CAAR,CAAA;CAEA,EAA0C,CAAR,CAAtB,MAAN;CAGJ,EAA6B,CAAR,CAAA,CAArB;CAAA,EAAQ,CAAR,CAAQ,GAAR;QAAA;CACA,EAA6B,CAAR,CAAA,CAArB;CAAA,EAAQ,EAAR,GAAA;QADA;CAAA,EAIQ,CAAI,CAAZ,CAAA;CAXF,IAIA;CAUA,GAAA,CAAS;CAAT,YAA8B;MAA9B;AAA0C,CAAD,YAAA;MAhBpB;CAAvB,EAAuB;CAAvB"
-}
deleted file mode 100644
--- a/devtools/client/framework/test/doc_empty-tab-01.html
+++ /dev/null
@@ -1,14 +0,0 @@
-<!-- Any copyright is dedicated to the Public Domain.
-     http://creativecommons.org/publicdomain/zero/1.0/ -->
-<!doctype html>
-
-<html>
-  <head>
-    <meta charset="utf-8"/>
-    <title>Empty test page 1</title>
-  </head>
-
-  <body>
-  </body>
-
-</html>