Need to disable javascript in editor

VERIFIED FIXED in M15

Status

()

Core
Editor
P3
major
VERIFIED FIXED
19 years ago
16 years ago

People

(Reporter: Niccolò Gallarati, Assigned: Akkana Peck)

Tracking

Trunk
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(4 attachments)

(Reporter)

Description

19 years ago
Dr. Watson's description: access violation (0xc0000005), address 0x603bbd69
Procedure to replicate the error:
- open editor by selecting "edit page" from file menu
- open an html page with delayed popup window
- the javascript code opens the popup window after some seconds
- if you select the debug menu from the popup window, Mozilla crashes
HTML code to view a delayed popup window:
// begin of html code
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
   <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
   <meta name="Author" content="Nic Galla">
   <meta name="GENERATOR" content="Mozilla/4.5 [it] (WinNT; I) [Netscape]">
   <title>The Nic Galla's Official WebSite</title>
<script language="JavaScript">
<!--
function MM_timelinePlay(tmLnName, myID) { //v1.2
  //Copyright 1997 Macromedia, Inc. All rights reserved.
  var
i,j,tmLn,props,keyFrm,sprite,numKeyFr,firstKeyFr,propNum,theObj,firstTime=false;
  if (document.MM_Time == null) MM_initTimelines(); //if *very* 1st time
  tmLn = document.MM_Time[tmLnName];
  if (myID == null) { myID = ++tmLn.ID; firstTime=true;}//if new call, incr ID
  if (myID == tmLn.ID) { //if Im newest
    setTimeout('MM_timelinePlay("'+tmLnName+'",'+myID+')',tmLn.delay);
    fNew = ++tmLn.curFrame;
    for (i=0; i<tmLn.length; i++) {
      sprite = tmLn[i];
      if (sprite.charAt(0) == 's') {
        if (sprite.obj) {
          numKeyFr = sprite.keyFrames.length; firstKeyFr = sprite.keyFrames[0];
          if (fNew >= firstKeyFr && fNew <= sprite.keyFrames[numKeyFr-1]) {//in
range
            keyFrm=1;
            for (j=0; j<sprite.values.length; j++) {
              props = sprite.values[j];
              if (numKeyFr != props.length) {
                if (props.prop2 == null) sprite.obj[props.prop] =
props[fNew-firstKeyFr];
                else        sprite.obj[props.prop2][props.prop] =
props[fNew-firstKeyFr];
              } else {
                while (keyFrm<numKeyFr && fNew>=sprite.keyFrames[keyFrm])
keyFrm++;
                if (firstTime || fNew==sprite.keyFrames[keyFrm-1]) {
                  if (props.prop2 == null) sprite.obj[props.prop] =
props[keyFrm-1];
                  else        sprite.obj[props.prop2][props.prop] =
props[keyFrm-1];
        } } } } }
      } else if (sprite.charAt(0)=='b' && fNew == sprite.frame)
eval(sprite.value);
      if (fNew > tmLn.lastFrame) tmLn.ID = 0;
  } }
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function MM_initTimelines() {
    //MM_initTimelines() Copyright 1997 Macromedia, Inc. All rights reserved.
    var ns = navigator.appName == "Netscape";
    document.MM_Time = new Array(1);
    document.MM_Time[0] = new Array(1);
    document.MM_Time["Timeline1"] = document.MM_Time[0];
    document.MM_Time[0].MM_Name = "Timeline1";
    document.MM_Time[0].fps = 15;
    document.MM_Time[0][0] = new String("behavior");
    document.MM_Time[0][0].frame = 45;
    document.MM_Time[0][0].value =
"MM_openBrWindow('jukebox.htm','','width=470,height=116')";
    document.MM_Time[0].lastFrame = 45;
    for (i=0; i<document.MM_Time.length; i++) {
        document.MM_Time[i].ID = null;
        document.MM_Time[i].curFrame = 0;
        document.MM_Time[i].delay = 1000/document.MM_Time[i].fps;
    }
}
//-->
</script>
<script language="JavaScript">
         <!-- Hide
         function st(txt) {
         window.status = txt;return true;
         }
         // -->
</script>
<script language="JavaScript">
<!--
function MM_swapImgRestore() { //v2.0
  if (document.MM_swapImgData != null)
    for (var i=0; i<(document.MM_swapImgData.length-1); i+=2)
      document.MM_swapImgData[i].src = document.MM_swapImgData[i+1];
}

function MM_preloadImages() { //v2.0
  if (document.images) {
    var imgFiles = MM_preloadImages.arguments;
    if (document.preloadArray==null) document.preloadArray = new Array();
    var i = document.preloadArray.length;
    with (document) for (var j=0; j<imgFiles.length; j++) if
(imgFiles[j].charAt(0)!="#"){
      preloadArray[i] = new Image;
      preloadArray[i++].src = imgFiles[j];
  } }
}
function MM_swapImage() { //v2.0
  var i,j=0,objStr,obj,swapArray=new Array,oldArray=document.MM_swapImgData;
    for (i=0; i < (MM_swapImage.arguments.length-2); i+=3) {
    objStr = MM_swapImage.arguments[(navigator.appName == 'Netscape')?i:i+1];
    if ((objStr.indexOf('document.layers[')==0 && document.layers==null) ||
        (objStr.indexOf('document.all[')   ==0 && document.all   ==null))
      objStr =
'document'+objStr.substring(objStr.lastIndexOf('.'),objStr.length);
    obj = eval(objStr);
    if (obj != null) {
      swapArray[j++] = obj;
      swapArray[j++] = (oldArray==null ||
oldArray[j-1]!=obj)?obj.src:oldArray[j];
      obj.src = MM_swapImage.arguments[i+2];
  } }
  document.MM_swapImgData = swapArray; //used for restore

}
//-->
</script>
</head>
<body text="#000000" bgcolor="#FFF8E6" link="#0000EE" vlink="#551A8B"
alink="#FF0000" background="bar_sfum.jpg"
onLoad="MM_timelinePlay('Timeline1')"MM_preloadImages(bio2.jpgproject2.jpgphoto2
.jpgcurri2.jpghobby2.jpgdownload2.jpglinks2.jpgguest2.jpg','#865883739078')">
<div id="Layer1" style="position:absolute; left:194px; top:15px; width:609px;
height:26px; z-index:1">
  <div align="center"> <a href="bio.htm" target="picture"
onMouseOut="MM_swapImgRestore()"
onMouseOver="MM_swapImage('parent.frames[\'bar\'].document.layers[\'Layer1\'].do
cument.Image3','parent.frames[\'bar\'].document.Image3','bio2.jpg','#86588273056
2');window.status=' Una breve biografia su di me';return true"><img
name="Image3" border="0" src="bio1.jpg" width="31" height="18"></a>
    <a href="#" onMouseOut="MM_swapImgRestore()"
onMouseOver="MM_swapImage('parent.frames[\'bar\'].document.layers[\'Layer1\'].do
cument.Image4','parent.frames[\'bar\'].document.Image4','project2.jpg','#8658827
55781');window.status=' I progetti che ho in cantiere';return true"><img
name="Image4" border="0" src="project1.jpg" width="69" height="18"></a>
    <a href="#" onMouseOut="MM_swapImgRestore()"
onMouseOver="MM_swapImage('document.layers[\'Layer1\'].document.Image5','documen
t.Image5','photo2.jpg','#865883657968');window.status=' Se vuoi vedere come sono
quello è il posto giusto';return true"><img name="Image5" border="0"
src="Photo1.jpg" width="58" height="18"></a>
    <a href="#" onMouseOut="MM_swapImgRestore()"
onMouseOver="MM_swapImage('document.layers[\'Layer1\'].document.Image6','documen
t.Image6','curri2.jpg','#865883669437');window.status=' Il mio curriculum di
lavoro personale';return true"><img name="Image6" border="0" src="curri1.jpg"
width="95" height="18"></a>
    <a href="#" onMouseOut="MM_swapImgRestore()"
onMouseOver="MM_swapImage('document.layers[\'Layer1\'].document.Image7','documen
t.Image7','hobby2.jpg','#865883691843');window.status=' Il mio hobby non è solo
la informatica clicca qui';return true"><img name="Image7" border="0"
src="hobby1.jpg" width="55" height="18"></a>
    <a href="#" onMouseOut="MM_swapImgRestore()"
onMouseOver="MM_swapImage('document.layers[\'Layer1\'].document.Image8','documen
t.Image8','download2.jpg','#865883706171');window.status=' Programmi gratis da
tenere sempre a portata di mano';return true"><img name="Image8" border="0"
src="download1.jpg" width="82" height="18"></a>
    <a href="#" onMouseOut="MM_swapImgRestore()"
onMouseOver="MM_swapImage('document.layers[\'Layer1\'].document.Image9','documen
t.Image9','links2.jpg','#865883721953');window.status=' Una raccolta di siti
passati alla mia lente di ingrandimento';return true"><img name="Image9"
border="0" src="links1.jpg" width="45" height="18"></a>
    <a href="#" onMouseOut="MM_swapImgRestore()"
onMouseOver="MM_swapImage('document.layers[\'Layer1\'].document.Image10','docume
nt.Image10','guest2.jpg','#865883739078');window.status=' Il libro degli ospiti
ovvero il posto dove puoi lasciare un tuo commento';return true"><img
name="Image10" border="0" src="guest1.jpg" width="89" height="18"></a>
  </div>
</div>
<center>
  <img src="bar_back.jpg" width="640" height="49">
</center>

</body>
</html>
// end of html code
note: you should create a page called jukebox.htm
note2: the javascript code is generated by Macromedia Dreamweaver 2 and works
fine on Netscape 4.x and IE 5.0
System configuration:
Windows NT Server 4.00 Service Pack 5 English version w/multiproc support
mozilla build id: 1999070308
display resolution: 1024x768
Hardware configuration:
Dual Pentium II 350
M/B ASUS P2B-DS
256 Mb RAM DIMM PC100
HD 9.1 Gb IBM U2WSCSI
SoundBlaster Live! w/ LiveWare 2.0
ASUS RIVA TNT 16 Mb AGP
DVD-ROM 6x
HP Cd-Writer 7200i
Trust Communicator 33.6K external modem

Message from who reads this bug description:
if you want more details or the files used to replicate the bug, write me at
nicgalla@yahoo.com
(Reporter)

Comment 1

19 years ago
Created attachment 699 [details]
the html page with delayed popup window

Updated

19 years ago
Assignee: don → buster
Component: Browser-General → Editor

Updated

19 years ago
Assignee: buster → sfraser

Comment 2

19 years ago
assigning to simon.  I don't know why this was marked a blocker.  Could the
person who set the severity please comment?  Otherwise, it should be considered
medium priority.

Updated

19 years ago
Assignee: sfraser → buster

Comment 3

19 years ago
Reassign to buster. The issue here is that we need to disable JavaScript
in the editor window.

Updated

19 years ago
Assignee: buster → akkana
Summary: mozilla crashes selecting debug menu in edit mode → mozilla crashes selecting debug menu in edit mode (Need to disable javascript in editor)
Target Milestone: M10

Comment 4

19 years ago
assigned to akkana.  Disabling javascript in the editor window is already on our
schedule for M10.
(Reporter)

Updated

19 years ago
Severity: blocker → critical
(Reporter)

Comment 5

19 years ago
I havn't read the severity option's meaning, the option blocker isn't
appropriate. I've changed it to Critical, because this bug cause mozilla to
crash. I'm sorry... good work!
(Assignee)

Updated

19 years ago
Status: NEW → ASSIGNED
(Assignee)

Comment 6

19 years ago
Changing summary to reflect the real problem.
Summary: mozilla crashes selecting debug menu in edit mode (Need to disable javascript in editor) → Need to disable javascript in editor
(Assignee)

Updated

19 years ago
Target Milestone: M10 → M11
(Assignee)

Comment 7

19 years ago
This seems to have been moved to M11 on the editor schedule.
(Assignee)

Updated

18 years ago
Target Milestone: M11 → M14
(Assignee)

Comment 8

18 years ago
Not critical for beta.

Updated

18 years ago
QA Contact: leger → sujay

Comment 9

18 years ago
Updating QA Contact.
(Assignee)

Comment 10

18 years ago
This looks like a big job and isn't marked as beta1 -- moving off to M15. 

The best method seems to be to add something to the nsHTMLContentSink to disable
evaluation of JS, but there's currently no way to get the document which will
become the editor document -- the document gotten from the content area webshell
in nsEditorShell::OnStartDocumentLoad does not seem to be the right document.
Severity: critical → major
Target Milestone: M14 → M15

Comment 11

18 years ago
Is there any chance of making this a pref (disabled by default)?  There are a 
couple of reasons why:
1. For future flexibily as web pages (and the authoring of them) become more 
interacive.
2. I need it!!
(Assignee)

Comment 12

18 years ago
You want to be able to switch JavaScript on but still edit the contents?  If you
edit a string that was produced by JS, what change should go into the dom tree
and the output?  Or do we just make any JS-generated content uneditable, and
beep (or something) if the user tries to change it?

At any rate, this sounds like it would be a hard problem with lots of questions
that would need to be answered.  I'd recommend filing a separate bug
(enhancement request) on that issue and we can track the various sub-issues
there.

There's another issue, something that's easier and which I'd very much like to
see: ability to edit the source (not the executed result) of script tags.  I
just realized a few days ago that source editing would be easier than I'd
previously thought, and I bet I can implement a basic source editor real soon. 
I filed bug 27939 to myself as a reminder.

Comment 13

18 years ago
editing a document with javascript active is a really tough problem, not one 
that's likely to be solved in this code base.  since javascript fires 
asynchronously, there's all kinds of places where things would get messed up, or 
at best the user would get very unexpected results.  For example, what if I'm in 
the middle of editing a table and something in javascript deletes the table from 
the document?  Not to mention the state problems with the undo system, the 
problems with presenting a user interface for editing onto a dynamic 
document, ...
What's the benefit of Javascript being active.  Isn't a special preview mode
enough, a la 4.x?
(Assignee)

Comment 15

18 years ago
Got it!  Attaching patch, will request review.
OS: Windows NT → All
Hardware: PC → All
(Assignee)

Comment 16

18 years ago
Created attachment 6903 [details] [diff] [review]
Patch to allow for disabling JS
(Assignee)

Comment 17

18 years ago
Created attachment 6911 [details] [diff] [review]
Better patch, changing fewer APIs
(Assignee)

Comment 18

18 years ago
Created attachment 6919 [details] [diff] [review]
Cleaner patch, incorporating some suggestions from sfraser
(Assignee)

Comment 19

18 years ago
Fixed!  There's some discussion of making the fix more complete ... but the
basic fix is in.
Status: ASSIGNED → RESOLVED
Last Resolved: 18 years ago
Resolution: --- → FIXED

Comment 20

18 years ago
verified in 3/28 build.
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.