incubator-adffaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mat...@apache.org
Subject svn commit: r495893 - /incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/Core.js
Date Sat, 13 Jan 2007 12:53:29 GMT
Author: matzew
Date: Sat Jan 13 04:53:29 2007
New Revision: 495893

URL: http://svn.apache.org/viewvc?view=rev&rev=495893
Log:
applied fix for ADFFACES-351. Thanks to Blake Sullivan

Modified:
    incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/Core.js

Modified: incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/Core.js
URL: http://svn.apache.org/viewvc/incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/Core.js?view=diff&rev=495893&r1=495892&r2=495893
==============================================================================
--- incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/Core.js
(original)
+++ incubator/adffaces/trunk/trinidad/trinidad-impl/src/main/javascript/META-INF/adf/jsLibs/Core.js
Sat Jan 13 04:53:29 2007
@@ -572,28 +572,62 @@
   return maxWidth + offsetLeft;
 }
 
+/**
+ * Safely returns the parent window of a window, or undefined if security doesn't allow us
to
+ * retrieve the parent
+ */
+function _getParentWindow(currWindow)
+{
+  var parentWindow = currWindow.parent;
 
-function _getTop(
-  element
-  )
+  try
+  {
+    // dummy read to test security error
+    parentWindow.name;
+    
+    return parentWindow;
+  }
+  catch (e)
+  {
+    return undefined;
+  }
+}
+
+/**
+ * Returns the window for the document
+ */
+function _getWindowForDocument(document)
 {
-  if (!(_agent.isGecko || _agent.isSafari))
+  if (_agent.isIE)
   {
-    return top;
+    return document.parentWindow;
   }
   else
   {
-    var currWindow = (element)
-                       ? element.window
-                       : window;
-
-    while (currWindow.parent && (currWindow.parent != currWindow))
-    {
-      currWindow = currWindow.parent;
-    }
+    return document.defaultView;
+  }
+}
 
-    return currWindow;
+/**
+ * Safely retrieve the top accessible window
+ */
+function _getTop(element)
+{  
+  var initialDocument = (element)
+                          ? element.ownerDocument
+                          : document;
+                       
+  // since top might be in another domain, crawl up as high as possible manually
+  var currWindow = _getWindowForDocument(initialDocument);
+  var currParentWindow = _getParentWindow(currWindow);
+  
+  while (currParentWindow && (currParentWindow != currWindow))
+  {
+    currWindow = currParentWindow;
+    currParentWindow = _getParentWindow(currWindow);
   }
+
+  return currWindow;
 }
 
 
@@ -963,6 +997,7 @@
   // within a frame.  So, we check for the _abandoned property
   // on the "top" window.
   var topWindow = _getTop();
+  
   return topWindow._abandoned;
 }
 
@@ -3589,8 +3624,7 @@
 function _submitPartialChange(
   form,
   doValidate,
-  parameters
-  )
+  parameters)
 {
   // If there's no PPR iframe, then just perform a normal,
   // full-page submission.
@@ -3610,9 +3644,11 @@
   // We need to set the target of the form to be the PPR iframe.
   // Save the old target and set the new one.
   var oldTarget = form.target;
-  if(!_agent.isPIE){
-  form.target = _pprIframeName;
+  if(!_agent.isPIE)
+  {
+    form.target = _pprIframeName;
   }
+  
   // Before we fire, update the request count
   _pprRequestCount++;
 
@@ -3621,13 +3657,13 @@
   // IE only adds to the history list if something has already been done on
   // this page, so until there has been some action, we don't
   // increment/decrement at all.
-  if ((!_agent.isIE) || parent._pprSomeAction)
+  if (!_agent.isIE || window._pprSomeAction)
   {
     delta = 1;
   }
   _pprSubmitCount += delta;
 
-  parent._pprSomeAction = true;
+  window._pprSomeAction = true;
 
   // block all mouse clicks until the submit is done
   if (!_agent.isPIE)
@@ -3694,7 +3730,7 @@
   var toLoadArray = new Array();
   var toLoadIndex = 0;
 
-  if (window["_pprLibraries"] != (void 0))
+  if (window["_pprLibraries"] != undefined)
   {
     // loop through each library in _pprLibraries
     // if it is not in the cached libraries list, then
@@ -4635,7 +4671,9 @@
   // If we're inside a frameset, and the top frame wants
   // reloads blocked, install a _noReload handler.
   // chain _monitor also if that is already set.
-  if ((self != top) && top["_blockReload"])
+  var topWindow = _getTop();
+  
+  if ((self != topWindow) && topWindow["_blockReload"])
   {
     // If _monitor is already set on document.onkeydown, then
     // chain _noReload and _monitor by calling another function which
@@ -5560,4 +5598,4 @@
 }
 
 // regular expression to gather whitespace at beginning and end of line
-TrUIUtils._TRIM_ALL_RE = /^\s*|\s*$/g;
\ No newline at end of file
+TrUIUtils._TRIM_ALL_RE = /^\s*|\s*$/g;



Mime
View raw message